chrisjames25
Registered User.
- Local time
- Today, 18:55
- Joined
- Dec 1, 2014
- Messages
- 404
Hi all. I have a form with 2 textboxes. The first textbox is txt_newtier1 and second is txt_confirmtier1. Basically you enter a new name in first text box and then reenter it in second textbox to ensure inputter has entered it correctly.
After inputting the data in the first textbox I run a dcount to ensure this isn't duplicating a name already in existence.
My code is as follows:
Work fine unless i have entered some info in txt_newtier1 and then delete it and tab out of textbox. I get an invalid use of null error message.
Can anyone see why from the code? Any help as ever much appreciated.
After inputting the data in the first textbox I run a dcount to ensure this isn't duplicating a name already in existence.
My code is as follows:
Code:
Private Sub Txt_NewTier1_AfterUpdate()
Dim msg, style, title, response, MyString, field, Source, criteria
field = StrTable
Source = "Tbl_" & field
criteria = field & "= '" & Replace(Me.Txt_NewTier1, "'", "''") & "'"
If DCount(field, Source, criteria) > 0 Then
msg = "This " & StrTier11 & " already exsits!!!"
style = vbOKOnly + vbExclamation
title = StrTier1 & " Duplicate Error"
response = MsgBox(msg, style, title)
Me.Txt_NewTier1.Value = ""
'Me.Cmd_Add.SetFocus
Me.Cmd_ChangeTier1.SetFocus
Me.Txt_NewTier1.SetFocus
Dim vSearchString As String
Exit Sub
End If
Work fine unless i have entered some info in txt_newtier1 and then delete it and tab out of textbox. I get an invalid use of null error message.
Can anyone see why from the code? Any help as ever much appreciated.