WineSnob
Not Bright but TENACIOUS
- Local time
- Today, 08:25
- Joined
- Aug 9, 2010
- Messages
- 211
I am trying to set the value of txtCPdate to blank field If Me.txtCPno.value does not contain certain values. Here is what I have. It works correctly when then txtCPno = 220160 or 225203 or 225204 or "22051C". I want it to change to blank if you change the txtCPno to something other than the above. Right now it retains the value of the last date.
So if txtCPno <> 220160 or 225203 or 225204 or "22051C" Then txtCPdate = "". However this control filed needs to be filled in with the correct date which comes from a book. The 4 values listed are the most common values.
Private Sub txtCPno_Change()
Me.txtCPdate.Value = ""
If Me.txtCPno.Value = 220160 Then
Me.txtCPdate.Value = "5 / 2 / 2003"
ElseIf Me.txtCPno.Value = 225203 Then
Me.txtCPdate.Value = "3 / 1 / 1984"
ElseIf Me.txtCPno.Value = 225204 Then
Me.txtCPdate.Value = "5 / 1 / 1985"
ElseIf Me.txtCPno.Value = "22051C" Then
Me.txtCPdate.Value = "3 / 23 / 1995"
Else
Me.txtCPdate.Value = ""
End If
End Sub
So if txtCPno <> 220160 or 225203 or 225204 or "22051C" Then txtCPdate = "". However this control filed needs to be filled in with the correct date which comes from a book. The 4 values listed are the most common values.
Private Sub txtCPno_Change()
Me.txtCPdate.Value = ""
If Me.txtCPno.Value = 220160 Then
Me.txtCPdate.Value = "5 / 2 / 2003"
ElseIf Me.txtCPno.Value = 225203 Then
Me.txtCPdate.Value = "3 / 1 / 1984"
ElseIf Me.txtCPno.Value = 225204 Then
Me.txtCPdate.Value = "5 / 1 / 1985"
ElseIf Me.txtCPno.Value = "22051C" Then
Me.txtCPdate.Value = "3 / 23 / 1995"
Else
Me.txtCPdate.Value = ""
End If
End Sub