Kryst51
Singin' in the Hou. Rain
- Local time
- Today, 13:33
- Joined
- Jun 29, 2009
- Messages
- 1,896
The following code is supposed to validate some information. If a certain combo is null or empty string then a message box should pop up. I added the red portion to the original code, as the message box would pop up if I deleted info from the box, but not if I had never selected an item in the list in the first place. Currently it just updates and goes to a new record when this is the case.
I am not sure that I am using the null correctly, or, maybe that isn't my problem at all. Any help with this problem is greatly appreciated.
Also, I don't know if you need to know this, but cmbWarehouse is storing a "number" type data into a junction table. but the display hides the number ID and only displays the text I want to show. (typical combo box use). Also I am using Access 2003
I was trying to make the form not scroll through previous records and had set the data entry to "yes", but then this disable going to a new record and also seemed not to save the current. So I had added a button to save the record, but then my validation didn't work. So I deleted the button, the code behind the button, and set the data entry back to "no". I don't know if this could have caused problems.
I am not sure that I am using the null correctly, or, maybe that isn't my problem at all. Any help with this problem is greatly appreciated.
Also, I don't know if you need to know this, but cmbWarehouse is storing a "number" type data into a junction table. but the display hides the number ID and only displays the text I want to show. (typical combo box use). Also I am using Access 2003
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim part1 As String
Dim part2 As String
part1 = "As this Nonconformance is a warehouse error "
part2 = "You must specify the warehouse for reporting purposes"
If Me.cmbErrorCode.Column(3) = "W" Then
If Len([COLOR=red]Nz([/COLOR]Me.cmbWarehouse[COLOR=red], "")[/COLOR] & vbNullString) = 0 Then
MsgBox (part1 & part2)
Cancel = True
Me.cmbWarehouse.SetFocus
End If
End If
End Sub
I was trying to make the form not scroll through previous records and had set the data entry to "yes", but then this disable going to a new record and also seemed not to save the current. So I had added a button to save the record, but then my validation didn't work. So I deleted the button, the code behind the button, and set the data entry back to "no". I don't know if this could have caused problems.