Subform Required Field?

michaeljohannes

Registered User.
Local time
Today, 11:53
Joined
May 3, 2007
Messages
67
Hello Access Programmers,

I have a new field I've recently added to a subform that I want to be required before tabbing to the next available field.

How can I control the user's action to disallow 'tabbing' over this required field? (ie, if they try, they get an err message pop up saying "Sorry, you must fill in the required field 'required field' " ?

I think there's a really easy way to do this using the VB script but I'm sort of stuck. Any help/advice is much appreciated!

Best,
Mike
 
I think the "On Exit" event in the properties for the control will give you what you want. You can create VBA code or a macro to check the value, put up a message box, and cancel the exit control event.
 
Cheers, George. Thanks for the help.

The On Exit event works, but it still 'tabs' to the next field. Is there a way I can force the user to stay where they are?
 
I tried this (warrantyAmount is my control name) in my On Exit event for WarrantyAmount. But the problem still persists. I seem to recall that subforms have different syntax like:

Me!JobsTableSubform.Form.WarrantyAmount.SetFocus

but that didn't work either.


Private Sub WarrantyAmount_Exit(Cancel As Integer)
If IsNull(Me.WarrantyAmount) = True Then
MsgBox "The Warranty Amount is a required field."
Me.WarrantyAmount.SetFocus
End If
End Sub
 
Solved the problem. I needed to add:

cancel = true

below
Me.WarrantAmount.SetFocus

thanks,
M
 

Users who are viewing this thread

Back
Top Bottom