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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Before Update Catch 22

Status
Not open for further replies.

BikeToWork

Programmer
Jun 16, 2010
50
0
0
US
I have a main form with two subforms in it. One of the business rules is that there must be data in the two subforms before the record in the main form is saved. The problem is that the record in the main form is automatically saved when either of the subforms is entered. Therefore, if I test for the presence of data in the subforms and put "Cancel = True" in the BeforeUpdate event for the main form if either of them is empty, the application won't let me enter the subforms to enter the data. Does anyone know of a workaround for this? Should I use a different event for data validation? Any advice is much appreciated.
 
Without actually trying this one, I think you have to save the main record first before relating child records. So I would try a trick.

Try in the current event which will fire as you leave the record. In the current event run a query or dlookup to return the ID of any record without the required child records. Do a findfirst to go to that record. Pop up a message saying that you have to delete the record or add child information. This will look as if you can not leave the record without the child information. May need to also but the code in the close event (not sure if you get a current before a close).
 
How are ya BikeToWork . . .
BikeToWork said:
[blue] ... the record in the main form is automatically saved when either of the subforms is entered.[/blue]
The same thing will happen when you move between subforms. So your fighting access normal navigation.

I'd suggest an [blue]unbound[/blue] form with two boxed in areas made to look like subforms as a data entry form. When validation allows it (after hitting a save button), you can write the data to the tables using [blue]append queries[/blue].

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top