T
Tom Wickerath
Hi Dinger188,
Try the following variation of your code:
'***************BEGIN CODE*********************
Option Compare Database
Option Explicit
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
Const conBtns As Integer = vbOKOnly + vbCritical + _
vbDefaultButton2 + vbApplicationModal
Dim intUserResponse As Integer
If IsNull(Me.Date) Then
Cancel = True
intUserResponse = MsgBox("Complete the INCIDENT DATE Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Date.SetFocus
ElseIf IsNull(Me.Nature_of_call) Then
Cancel = True
intUserResponse = MsgBox("Complete the NATURE OF CALL Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Nature_of_call.SetFocus
ElseIf IsNull(Me.Called_By) Then
Cancel = True
intUserResponse = MsgBox("Complete the CALLED BY Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Called_By.SetFocus
ElseIf (Me.Nature_of_call) = "Fire" Then
If IsNull(Me.Type_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the TYPE OF FIRE Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Type_of_Fire.SetFocus
ElseIf IsNull(Me.Cause_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the CAUSE OF FIRE Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Cause_of_Fire.SetFocus
End If
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_BeforeUpdate..."
Resume ExitProc
End Sub
'***************END CODE**********************
A couple of suggestions:
1.) Date is a reserved word. You should avoid using any reserved words, or
special characters (including spaces) in anything that you assign a name to
in Access. Here are some reference Knowledge Base articles:
Special characters that you must avoid when you work with Access
databases
http://support.microsoft.com/?id=826763
Reserved Words in Microsoft Access
http://support.microsoft.com/?id=286335
List of reserved words in Jet 4.0
http://support.microsoft.com/?id=321266
Here are two other articles on the topic of naming conventions:
Commonly used naming conventions
http://www.mvps.org/access/general/gen0012.htm
http://www.xoc.net/standards/default.asp
2.) You might want to consider using periods, instead of exclaimation marks,
in the text of your message boxes. Your current feedback "shouts" at your
users.
By the way, my step-dad is a retired Captian of the Ellensburg Fire
Department, located in Ellensburg, WA. (USA).
Tom
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
Try the following variation of your code:
'***************BEGIN CODE*********************
Option Compare Database
Option Explicit
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
Const conBtns As Integer = vbOKOnly + vbCritical + _
vbDefaultButton2 + vbApplicationModal
Dim intUserResponse As Integer
If IsNull(Me.Date) Then
Cancel = True
intUserResponse = MsgBox("Complete the INCIDENT DATE Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Date.SetFocus
ElseIf IsNull(Me.Nature_of_call) Then
Cancel = True
intUserResponse = MsgBox("Complete the NATURE OF CALL Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Nature_of_call.SetFocus
ElseIf IsNull(Me.Called_By) Then
Cancel = True
intUserResponse = MsgBox("Complete the CALLED BY Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Called_By.SetFocus
ElseIf (Me.Nature_of_call) = "Fire" Then
If IsNull(Me.Type_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the TYPE OF FIRE Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Type_of_Fire.SetFocus
ElseIf IsNull(Me.Cause_of_Fire) Then
Cancel = True
intUserResponse = MsgBox("Complete the CAUSE OF FIRE Field!", _
conBtns, "STOP! Incomplete
Field")
Me.Cause_of_Fire.SetFocus
End If
End If
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure Form_BeforeUpdate..."
Resume ExitProc
End Sub
'***************END CODE**********************
A couple of suggestions:
1.) Date is a reserved word. You should avoid using any reserved words, or
special characters (including spaces) in anything that you assign a name to
in Access. Here are some reference Knowledge Base articles:
Special characters that you must avoid when you work with Access
databases
http://support.microsoft.com/?id=826763
Reserved Words in Microsoft Access
http://support.microsoft.com/?id=286335
List of reserved words in Jet 4.0
http://support.microsoft.com/?id=321266
Here are two other articles on the topic of naming conventions:
Commonly used naming conventions
http://www.mvps.org/access/general/gen0012.htm
http://www.xoc.net/standards/default.asp
2.) You might want to consider using periods, instead of exclaimation marks,
in the text of your message boxes. Your current feedback "shouts" at your
users.
By the way, my step-dad is a retired Captian of the Ellensburg Fire
Department, located in Ellensburg, WA. (USA).
Tom
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________