require data only in form

laurat

Registered User.
Local time
Today, 04:30
Joined
Mar 21, 2002
Messages
120
OK, quick and easy question I think.

Is there a way to make a field required just in one specific form and not in the table.

For example, I have two forms based off of one table. There is a quantity field that is in both forms, the users want it to be optional to enter in the first form but required in the second form.

Thanks for any help!!
 
Set the field in the table to Required.No

In the form that you want to make it mandatory in:

Set the form properties, Close Button to No
and the Navigation buttons to No
On the command buttons that you create for Close, or navigation include the following as part of your close statment:

If ([Quantity]=IsNull) Then
MsgBox "You must enter a quantity"
Else
DoCmd.Close
EndIf
 
Hi
In the form where it is Required.
You could write some code OnExit of the field so that it checks to make sure they've added something.

If IsNull(Me.FieldName) then
Msgbox "No data entered"
DoCmd.GotoControl "FieldName"

End If

Not too sure without checking if this is 100% but along the lines you need.

Hope this helps
Col

Adrianna beat me to it!!
 
I tried both of these suggestions with no luck. Maybe I did it incorrectly and just need a little more explanation. I did not get any errors but it still closed the form even though quantity contained a Null value. Any further input would be greatly appreciated. Thank you.
 
Some of those events have the Cancel variable

make sure you set Cancel = True where appropriate to stop it from completing its action anyway.
 
Ignore my last post. I just tried a combination of both suggestions and came up with something that works.

Thank you.
 

Users who are viewing this thread

Back
Top Bottom