Can Access solve the following problem?

message from =?Utf-8?B?TmFyd2U=?= on 20 May 2004
On page 1 of a patient questionnaire, an individual fails to check a box that indicates that they are pregnant. However, on page 3, they are answering portions of the questionnaire that only those individuals who are pregnant should be responding to.

What my manager needs is for the database to recognize, and direct the users attention to, these kinds of problems. Can Access do this? And, if so, where do I begin to learn how to deal with these problems? I am a c# programmer. Can I resolve these kinds of issues programmatically, or are there easier solutions?

Any help would be greatly appreciated.

Thanks
 
John Vinson replied to =?Utf-8?B?TmFyd2U=?= on 20 May 2004
There are a couple of ways to do this - "Table Validation Rules"
would, for example, cause an error message to be posted if the user
enters data into a pregnancy-related field if they checked no to
pregnancy (or, for that matter, if they are male!)

The messages can be confusing though; generally it would be better to
use VBA code in the Form in which they are entering data. Each control
on the Form has a BeforeUpdate event which can be canceled - one could
put code such as:

Private Sub txtDateOfConception_BeforeUpdate(Cancel as Integer)
If Me!Pregnant <> True Then
MsgBox "This field should only be filled out if you are pregnant."
Cancel = True
End If
End Sub

More sophisticated solutions are possible; for instance, one could
have the Enabled property of these controls all set to False so the
user would not be able to even click into the control. In the
AfterUpdate event of the Pregnant checkbox you could enable that set
of controls.

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 

Archived message: Can Access solve the following problem? (MS Access Forms)