Jump to content
Server Maintenance This Week. ×

Help with Script to check data with related record


This topic is 7126 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi!

Database A (master file) is related to Database B. I want to write a script that will allow me to enter a customer number into DB A and then have the script validate/check that there is a related record in DB B. If there is a related record I want to continue entering data in DB A but if there is no related record then I want to be able to enter a new record in DB B then go back to DB A and continue entering data. Can anyone help me with some suggestions?

Cheers

Link to comment
Share on other sites

Validating the relationship is pretty easy,

#From Database A

If[ DatabaseB::CustomerID ]

# There is a related record

End If

But this type of check isn't often used for entering new records. What is the data you are working with? Maybe there's a better process.

Link to comment
Share on other sites

I want to write a script that will allow me to enter a customer number into DB A and then have the script validate/check that there is a related record in DB B.

If [ IsEmpty(DatabaseB::CustomerNumber) ] ... boolean produces true (1) if there is no related record.

If there is a related record I want to continue entering data in DB A but if there is no related record then I want to be able to enter a new record in DB B then go back to DB A and continue entering data.

There is no need to jump to DatabaseB and create a record. Your relationship itself can do this for you. Turn on Allow Creation of Related. Place a field from Database B on your Database A layout (anything except the CustomerNumber. Let Users enter a value in it, and your related Database B will be automatically created if none exists matching that CustomerNumber.

You can also just take care of this behind the scenes without placing a field from B on your A layout ... use script with the If[] test above. If true (no related record), use script to set any B field (except the CustomerNumber) and your related record will be created and the associated CustomerNumber will be automatically inserted in B for you.

Link to comment
Share on other sites

This topic is 7126 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.