Question : Error 94, Invalid use of Null Fiels

PROBLEM
I am getting the above error message as it relates to form:
frmHazardLookup_VER1.

PROBLEM DETAILS
The table that supports the query that populates the form "frmHazardLookup_VER1" is:
tblHazard_and_Category_Lookup_VER1.

The query that populates the form is:
qryHazard_and_Category_Lookup_VER1.

The table "tblHazard_and_Category_Lookup_VER1" can not have Null valuse in it.

WHAT I HAVE TRIED
I have used the NZ function in the query and no success.

CODE THAT IS LOCKING THE HAZARD TEXTBOX
The following code was added to the form:
frmHazardLookup_VER1
to prevent users from changing and or deleting the pre-populated data in table:
tblHazard_and_Category_Lookup_VER1.
while still allowing users to add and or edit their own data.

HOW TO RECREATE THE ERROR
1. Log in.
2. Click "Edit AHA"
3. Select any AHA to edit
4. Click next until you see the error message.
NOTE: You can make this error go away by opening :
tblHazard_and_Category_Lookup_VER1
and entering a value in the null field

OTHER WAYS TO GET THIS ERROR
1. Add the missing data to table
tblHazard_and_Category_Lookup_VER1.
2. 1. Log in.
3. Click "Edit AHA"
4. Select any AHA to edit
5. Click Next until you get to form:
frmSelectHazardsDirectly_VER1
6. Click the "Add/Edit Hazards Button"
7. Click the Add Record button
8. Enter data in the Hazards field
9. Delete the data you just added to the Hazards fiels
10. Clcik the clos button
See error message.



Answer : Error 94, Invalid use of Null Fiels

It seems you have set your table such that not accept null values. The easy way out is to remove this requirement. If not possible then you need to validate all your fieds on in the form's in BeforeUpdate event using:

If Nz(Me!txFName,"")="" Then
MsgBox "You need to enter a valid value for First Name."
Cancel=True
End IF

Add a similar code for each txt box with entery required setting in the table.

Mike
Random Solutions  
 
programming4us programming4us