exit form

  • Thread starter plgii via AccessMonster.com
  • Start date
P

plgii via AccessMonster.com

I have a form with 4 tab pages
on the 2 tab page I have a subform that adds records to a table via 2 combo
boxes.

I have been able to stop user from leaving a combo control blank or skipping
to the next combo control, but if user clicks the Exit command button on the
main form, from the 2nd combo control, it prompts that value has to be
selected but the gives error:

"You cannot add or change record because a related record is required"

how can I stop this so form will close and undo the 1st combo selection and
not give error?
 
G

Guest

Can you give more info as to the setup of the forms and control?

You are getting this message because the foreign key in the subform is not
being stored and thus, the new record being created can't be stored because
the foreign key's Required property in the underlying table is most likely
set to True (this is not a bad thing).

Seth
 
R

Ron Hinds

In the Unload event of the form, add the following code:

Private Sub Form_Unload(Cancel As Integer)
Me.Undo
End Sub
 
P

plgii via AccessMonster.com

any way to get a sample of db to you?

Seth said:
Can you give more info as to the setup of the forms and control?

You are getting this message because the foreign key in the subform is not
being stored and thus, the new record being created can't be stored because
the foreign key's Required property in the underlying table is most likely
set to True (this is not a bad thing).

Seth
I have a form with 4 tab pages
on the 2 tab page I have a subform that adds records to a table via 2 combo
[quoted text clipped - 9 lines]
how can I stop this so form will close and undo the 1st combo selection and
not give error?
 

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