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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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