Validating required fields

azzajones

New member
Local time
Today, 14:33
Joined
Mar 27, 2007
Messages
4
Hi everyone,

I have a database for recording results of dog shows. I have a main form (frmShows) and a subform for the results (subfrmShowResults)

when entering results user should select the following: DogName, Class & Award for each entry (they are all combBoxes). Because calculating the points requires all three to be entered, I have set them all to "required" in the tables.

I use a compositeID (Indexed - no duplicates allowed) to prevent someone from awarding the same dog twice in one show.

Further, some of the Classes and Awards are gender-specific, so I want to prevent the user from selecting a Male dog and enter them in a female Class or award them a female Award, this is where I have a problem.

In the code of the form I use DLookup to find the applicable "Sex" in the Class and/or Award tables and compare them to the DogSex, if there is a mis-match, display a message to the user and set that particular control (Class or Award) to ""

As soon as I set the value of that control to "" I get a run-time error because the field cannot contain a Null value because the required property for this field is set to 'True'

How can I make sure that all three field have data in them and that the user is only allowed to select valid options according to the gender of each dog?
 
Try setting the value of the combobox to =False rather than =""
 
Thanks Allan, works a treat. :)
 

Users who are viewing this thread

Back
Top Bottom