hardhitter06
Registered User.
- Local time
- Today, 04:07
- Joined
- Dec 21, 2006
- Messages
- 600
Hi all,
I have this code that requires me to enter in each of the fields in a form or else when the record is saved it will return an error message telling what fields still need to be filled in. It works fine, but when I hit the save button to verify if i'm missing any fields (even though I'm not), I want it to tell me the record has been saved so the user knows. If there are no fields missing right now, and you click the save button, nothing happens (although the record is saved).
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim blnError As Boolean
Dim strError As String
strError = "You are missing data for one or more of these fields:"
If IsNull(Me.[Account #]) Or Me.[Account #] = "" Then
blnError = True
strError = strError & "Account #,"
End If
If IsNull(Me.Vendor) Or Me.Vendor = "" Then
blnError = True
strError = strError & " and/or Vendor,"
End If
If IsNull(Me.[Total Amount]) Or Me.[Total Amount] = "" Then
blnError = True
strError = strError & " and/or Total Amount,"
End If
If IsNull(Me.Category) Or Me.Category = "" Then
blnError = True
strError = strError & " and/or Category,"
End If
If IsNull(Me.[Contract #]) Or Me.[Contract #] = "" Then
blnError = True
strError = strError & " Contact,"
End If
If IsNull(Me.[Term Begins]) Or Me.[Term Begins] = "" Then
blnError = True
strError = strError & " and/or Term Begins,"
End If
If IsNull(Me.[Term Ends]) Or Me.[Term Ends] = "" Then
blnError = True
strError = strError & " and/or Term Ends,"
End If
If IsNull(Me.[Record Date]) Or Me.[Record Date] = "" Then
blnError = True
strError = strError & " and/or Record Date,"
End If
If blnError Then
strError = Left(strError, Len(strError) - 1)
If MsgBox(strError & vbCrLf & "Are you sure you want to cancel." & vbCrLf & "If you do, the info will not be added.", vbQuestion + vbYesNo, "Close Confirmation") = vbNo Then
Cancel = True
End If
I have this code that requires me to enter in each of the fields in a form or else when the record is saved it will return an error message telling what fields still need to be filled in. It works fine, but when I hit the save button to verify if i'm missing any fields (even though I'm not), I want it to tell me the record has been saved so the user knows. If there are no fields missing right now, and you click the save button, nothing happens (although the record is saved).
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim blnError As Boolean
Dim strError As String
strError = "You are missing data for one or more of these fields:"
If IsNull(Me.[Account #]) Or Me.[Account #] = "" Then
blnError = True
strError = strError & "Account #,"
End If
If IsNull(Me.Vendor) Or Me.Vendor = "" Then
blnError = True
strError = strError & " and/or Vendor,"
End If
If IsNull(Me.[Total Amount]) Or Me.[Total Amount] = "" Then
blnError = True
strError = strError & " and/or Total Amount,"
End If
If IsNull(Me.Category) Or Me.Category = "" Then
blnError = True
strError = strError & " and/or Category,"
End If
If IsNull(Me.[Contract #]) Or Me.[Contract #] = "" Then
blnError = True
strError = strError & " Contact,"
End If
If IsNull(Me.[Term Begins]) Or Me.[Term Begins] = "" Then
blnError = True
strError = strError & " and/or Term Begins,"
End If
If IsNull(Me.[Term Ends]) Or Me.[Term Ends] = "" Then
blnError = True
strError = strError & " and/or Term Ends,"
End If
If IsNull(Me.[Record Date]) Or Me.[Record Date] = "" Then
blnError = True
strError = strError & " and/or Record Date,"
End If
If blnError Then
strError = Left(strError, Len(strError) - 1)
If MsgBox(strError & vbCrLf & "Are you sure you want to cancel." & vbCrLf & "If you do, the info will not be added.", vbQuestion + vbYesNo, "Close Confirmation") = vbNo Then
Cancel = True
End If