Actually, Tag is not a Reserved Word...it's a Control Property...so Pauls' untested suggestion of using Square Brackets won't work, you'll have to change the Control's Name, as he originally said. Oddly, though, you apparently can actually let the name of the Field, in the Table, remain as Tag!
Your validation code needs to be in the Form_BeforeUpdate event...not in the code for the Command Button; otherwise, if the user decides to quit entering Records and simply Close the Form/Database...and has forgotten to enter data in any of the Controls, that Record will be saved sans the data. Placing the code in the Form_BeforeUpdate event ensures that no Record will be saved only partially filled out, regardless of how the Current Record is exited.
Also, when referring to a Control on a Form, in that Form's code, it's much easier to to use the Me. construct, as in
Me.IP
rather than the longer reference of
[Forms]![coilf]![IP]
Here's a modification of your code, using the above and renaming your Control named Tag with the name TagNum.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.IP) Then
MsgBox "Check IP Number"
Me.IP.SetFocus
Cancel = True
Exit Sub
End If
If IsNull(Me.TagNum) Then
MsgBox "Check tag Number"
Me.TagNum.SetFocus
Cancel = True
Exit Sub
End If
If IsNull(Me.Original_Coil_Weight) Then
MsgBox "Check Coil Weight"
Me.Original_Coil_Weight.SetFocus
Cancel = True
Exit Sub
End If
If IsNull(Me.Coil_Start_Time) Then
MsgBox "Check Start Time"
Me.Coil_Start_Time.SetFocus
Cancel = True
Exit Sub
End If
End Sub
Now simply reduce the code of your Command Button to just what is needed to move to another, New Record, and when it is clicked Access will fire the Form_BeforeUpdate event, and the validation code will run.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007