Disallow null/allow null depending on the selection of another fie

F

Flydianslip

Can someone tell me if you can require a field (disallow null) depending on
the what a different field says? something like?

Private Sub Business_Area_AfterUpdate()
If Me.Business_Area = "Electronic Solutions - ES" Then
ON Order([Function]) WITH DISALLOW NULL

This doesnt work...I have a Combobox named "Business Area" when its field is
selected as "Electronic Solutions - ES" I want the adjacent Combobox which
Control Source is called "Function" to be a required field. This field is in
Table "Order" Field called "Function". But also I want if "Business Area" is
selected as anything else you can skip filling in the "Function" (allow null).
Thank you for any help.
 
L

Linq Adams via AccessMonster.com

First off, ***Function*** is a Reserved Word in Access, and shouldn't be
used as a field name.

Next, this type of validation, where you're validating one control based on
the value of a second control, has to be done in the Form_BeforeUpdate event,
something like this.

Private Sub Form_Current()
If Me.Business_Area = "Electronic Solutions - ES" And Nz(Me.
SecondComboboxName, "") = "" Then
MsgBox "SecondComboboxName Cannot Be Left Empty If Business Area Is
Electronic Solutions - ES"
Cancel = True
End If
End Sub
 

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