hardhitter06
Registered User.
- Local time
- Today, 02:50
- Joined
- Dec 21, 2006
- Messages
- 600
Hey All,
I have a pop up for (department input) on my contract form (contract input). The user selects the acct number, if the account number isnt in the system, the user then clicks the add department button which will open up the department input pop up form where the user can enter the acct number with the corresponding department. Works perfect!
The problem is when I only enter 1-3 fields and not all 4 i get an error message telling me I'm missing all 4 and not just the 1-3 missing fields.
Here is my code and please help me if you can. Thank you in advance.
Private Sub Form_Unload(Cancel As Integer)
Dim blnError As Boolean
Dim strError As String
strError = "You are missing data for "
If IsNull(Me.[Account Number]) Or Me.[Account Number] = "" Then
blnError = True
strError = strError & "Account Number,"
End If
If IsNull(Me.Contact) Or Me.Contact = "" Then
blnError = True
strError = strError & " Contact,"
End If
If IsNull(Me.Department) Or Me.Department = "" Then
blnError = True
strError = strError & " Department,"
End If
If IsNull(Me.Address) Or Me.Address = "" Then
blnError = True
strError = strError & " Address,"
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
End If
End Sub
I have a pop up for (department input) on my contract form (contract input). The user selects the acct number, if the account number isnt in the system, the user then clicks the add department button which will open up the department input pop up form where the user can enter the acct number with the corresponding department. Works perfect!
The problem is when I only enter 1-3 fields and not all 4 i get an error message telling me I'm missing all 4 and not just the 1-3 missing fields.
Here is my code and please help me if you can. Thank you in advance.
Private Sub Form_Unload(Cancel As Integer)
Dim blnError As Boolean
Dim strError As String
strError = "You are missing data for "
If IsNull(Me.[Account Number]) Or Me.[Account Number] = "" Then
blnError = True
strError = strError & "Account Number,"
End If
If IsNull(Me.Contact) Or Me.Contact = "" Then
blnError = True
strError = strError & " Contact,"
End If
If IsNull(Me.Department) Or Me.Department = "" Then
blnError = True
strError = strError & " Department,"
End If
If IsNull(Me.Address) Or Me.Address = "" Then
blnError = True
strError = strError & " Address,"
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
End If
End Sub