Dirty forms...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form and subform pair. on the master form there is an autonumber
field and a box called WOref that is needed for each record. The subform has
a combobox and textbox. I have noticed that if the combo on the subform is
selected before a WOref is entered the selection disapears (it is actually
saved with null refs) and the user will need to reselect their options. Any
suggestions on how to fix this. I have tried various combinations of sols
but to no avail ie such as:

change combos onfocu to show a msgbox and move focus to WOref.
(semi - works but user can still select option)

Playing with onExit or lostfocus of WOref

etc

Thanks in advance,
Kenny
 
If you are trying to prevent the user entering subform record before the
main form record, cancel the BeforeInsert event of the subform:
Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.Parent.NewRecord Then
Cancel = True
MsgBox "Enter the main form record first."
End If
end Sub

If you are trying to prevent the subform record being saved with a null
foreign key, open the subform's table in design view, select the foriegn key
field, and set its Required property to Yes.

If I have not understood your goal here, please post a reply.
 
Thank You - Works Perfetly!
Kenny

Allen Browne said:
If you are trying to prevent the user entering subform record before the
main form record, cancel the BeforeInsert event of the subform:
Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.Parent.NewRecord Then
Cancel = True
MsgBox "Enter the main form record first."
End If
end Sub

If you are trying to prevent the subform record being saved with a null
foreign key, open the subform's table in design view, select the foriegn key
field, and set its Required property to Yes.

If I have not understood your goal here, please post a reply.
 
I would recommend using a enabled/disabled approach whereby the subform
fields are shows as disabled/unavailable until the required fields on
the main form are entered.
 
Back
Top