required fields

fvd

Registered User.
Local time
Today, 04:14
Joined
Jul 11, 2003
Messages
12
Hi there,

I have a form (let's call it form1) on which it isn't allowed to skip a field, they all have to contain some data.
But putting those fields in the table to required is not an option because there are other forms based on that table on which it is allowed to skip some fields (because it's possible that the user does not have all the data to fill in to those fields) and in that case he receives an error-message that says that the records could not be saved because all fields in the table are set to 'required'.

So i tried to put the validationrules of those fields (in from1) to 'Is Not Null' but you still can skip the fields and leave the form without an error.
Does somebody know a solution???

Thanks already!!!
 
Use the BeforeUpdate() event of the form to check if the fields have data with the IsNull() function.
 
What exactly do you mean with the BeforeUpdate-Event?
And how do i have to use it?

Thank you for your help!
 
In the design of your form, call the form's properties and click on the events tab. You should see the Before Update event, click on the build button (3 dots on it) and select code builder. This will take you to the VBA screen. You can then use code to test for entries. Something like below:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsNull(yourControlNameHere) Then
   MsgBox("Enter your message here", vbCritical, "Enter MsgBox Title Here")
   yourControlName.SetFocus
   Cancel = True
End If
 

Users who are viewing this thread

Back
Top Bottom