Required field On Form

Paul Cooke

Registered User.
Local time
Today, 07:54
Joined
Oct 12, 2001
Messages
288
Hi, I have been scrolling through the posts to try and find an answer to my question, which is...

I have put a new combo box called "Givenby" into a form.

I need to ensure that a user must select a name from the list before they can continue filling in the form. If they try to leave the box empty i would like a msg box to prompt them.

I have tried numerous bits of "code" but my knowledge is very (VERY!!) basic.

I would be really grateful for any suggestions on how to solve problem cos its driving me nuts!!

Many thanks
 
Try this code in your combo box's On Lost Focus event

If IsNull([Givenby]) = True Then

MsgBox "Please select a name from the list", vbCritical, "No Name"
Me.Givenby.SetFocus
End If
 
Worked a treat

Thank you very much!
 
sorry just noticed after it displays the message it moves onto the next field. Is there anyway of stopping it doing this unless the user has entered a name in the combo box?
 
Hi there,

Just thinking about it you would also need to check this combo box is completed when your user closes the form.

If you want your user to follow a logical procedure i.e. only allow them on to the next control when the previous one is completed then use the code in the On GotFocus event of your next control
 
Another alternative is to use a macro ISNull([YourFieldName]) as the condition then Msgbox as the action. Underneath put ... in the condition and CancelEvent as the action. This will ensure they cannot leave the field blank.
 
Thank you Robert that works perfectly!!

Thanks Hayley as well
 

Users who are viewing this thread

Back
Top Bottom