mark curtis
12-07-2000, 09:36 AM
I have a form which uses some sub forms. My problem is that if a user enters data in one of the sub forms before the main form I get an error saying null/index. What I need to know is how to ensure that a user populates a field from the main form so a record ID is created. I also want a message box to inform them that they must fill in the defined field before they can proceed.
IDEAL: Open form, lock focus in title field, if user tries to tab out of field without entering data, load message box informing user to fill title field, once loaded release focus.
Thanks
Mark
Camon
12-07-2000, 10:29 AM
Either have the record Id automatically created or ask for it before you enter the main form. I used to have the problem when I created access programs that I would use the same form to lookup,create, and edit I have since adopted to policy of creating seperate forms to do these tasks that look very similar. however if you follow the same princable you could ask for teh record ID before there able to get into the Creat Form
Talismanic
12-07-2000, 11:37 AM
Try this:
Set your subforms enabled property to false then put this in your On_Exit event or what ever works for your situation:
Dim Answer As Variant
If IsNull(Me.YourControlName) Then
Answer = MsgBox("The text box can not be left blank", vbOKOnly, "Hey You!")
If Answer = vbOK Then Cancel = True
Exit Sub
Else
YourSubForm.Enabled = True
End If
This will check YourControlName for a null, if found the message will appear and an OK answer will put the focus back into the control if not the subform will be enabled and the focus can be put where you want.