Records in form and subform

M

Maracay

Hi gurus,

I have a form and a subform, the problem is that if I input the data in the
main form and I pass to the subform and I decided not to input any data in
the subform I end up with a record in the table form and any record in the
table of the subform, my question is if there is easy way to not to store
information in the table of the form until there is at lease 1 record stored
in the table subform

Any help would be appreciated
 
T

Tieske

if you ask me, it can't be done without VBA coding. Suppose you enter two
records simultaneously. Now before you save them, you need at least in one
table a linking value to the other table. This value isn't available unless
you save the record first. Chicken-egg thing.

one way to do it;
make your subform a modal popup form.
add a button to the mainform to enter data in the popup form
in the button_click event, save the data entered in the mainform
show the popupform (code execution halts until form closes)
now count values in the table of the subform, for example using dcount()
function
if the count returns 0, delete the record added in the mainform

another way
stick to the subform
create a vba Sub called "VerifyMainRecord" or something like that.
This sub should: count the number of records in the subform, related to the
record shown in the mainform. If count=0 then delete record in mainform
Now catch events (of mainform)
- mainform moves to different record (onCurrent)
- mainform closes (onClose)
and in those events call the "VerifyMainRecord" sub

I'm a vba coder myself, so maybe it can be done with macros as well....

regards,
Tieske
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top