Jump to content
Sign in to follow this  
susan7

Help with Script to check data with related record

Recommended Posts

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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