Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent data entered into a subform only

Status
Not open for further replies.

Tfrank

Technical User
Jun 19, 2001
30
US
I have a main form that also contains a subform and entering data into both fills data into two separate tables. The two tables are connected as a one-to-many relationship, where the data that goes into the main form and its related table is the ONE and the data input into the subform has the MANY side of the relationship. I have enforced referential integrity in the relationship between these two tables. The question I have is; that it is possible for a user to input data into the subform, put no data into the main form, then click back to previous record to look at something and then click forward to the record she was just working on. The problem I have is since no data was input into the mainform, the primary key never got set, so the data in the subform is now a orphan set of data that cannot be viewed. Is there a way that I can prevent a user from only entering data only into the subform without entering data into the main form before changing to a different record? In proper use of the database data should always be put into the mainform, but some users like to do things differently so I did to try a bullet proof the database.

Thanks for the help,

Tfrank
 
There are two ways that I can think of how you might handle this.

1) Don't let users do this, and give them a friendly error message.

2) Don't store the data directly in the tables. Use unbound controls and/or temporary tables until all of the data entry is completed, and then store the data in the main tables.

Your users would probably prefer option #2, but it involves much more work for you.

I'm sure there are other ways to handle it, but I haven't had my morning caffeine yet.

[morning]
 
I would almost prefer to use a simple message box that informs the users that he can't do this, as only about 5% of the users attempt to enter data into the subform only. Do you have suggestions on the best approach to check for this situation and then create a message window preventing this from happening?

Thanks,
Tfrank
 
The way I handled a similar situation in the database I've been developing is to keep the subform hidden (Visible property = False) until the appropriate information has been entered in the main form. I then make the subform visible, and move them to it, which saves the record for the main form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top