T
Tom
The function below throws an error message if the entered
data into textbox field/table is NOT unique.
After I acknowledge the error message, I would like
to "empty" the entered textbox field (instead of having
the cursor still "blink" at the end of the data value.
I have tried the following (below the line of code
containing the MsgBox "...."
BilletCode.SetFocus
BilletCode.Text = ""
This, however, does not work. Does anyone know how to
add the code that will clear the textbox?
Thanks,
Tom
********* This is the current function:
Private Sub BilletCode_BeforeUpdate(Cancel As Integer)
Dim strWhere As String
Dim varResult As Variant
If Not IsNull(Me.BilletCode) Then
If Me.BilletCode.Value = Me.BilletCode.OldValue
Then
'Do Nothing
Else
strWhere = "BilletCode = """ & Me.BilletCode
& """"
varResult = DLookup
("BilletCode", "tbl_BilletCodes", strWhere)
If Not IsNull(varResult) Then
Cancel = True
MsgBox "Billet code '" & varResult & "'
already exists. Please enter a new billet code or cancel
operation!"
End If
End If
End If
End Sub
data into textbox field/table is NOT unique.
After I acknowledge the error message, I would like
to "empty" the entered textbox field (instead of having
the cursor still "blink" at the end of the data value.
I have tried the following (below the line of code
containing the MsgBox "...."
BilletCode.SetFocus
BilletCode.Text = ""
This, however, does not work. Does anyone know how to
add the code that will clear the textbox?
Thanks,
Tom
********* This is the current function:
Private Sub BilletCode_BeforeUpdate(Cancel As Integer)
Dim strWhere As String
Dim varResult As Variant
If Not IsNull(Me.BilletCode) Then
If Me.BilletCode.Value = Me.BilletCode.OldValue
Then
'Do Nothing
Else
strWhere = "BilletCode = """ & Me.BilletCode
& """"
varResult = DLookup
("BilletCode", "tbl_BilletCodes", strWhere)
If Not IsNull(varResult) Then
Cancel = True
MsgBox "Billet code '" & varResult & "'
already exists. Please enter a new billet code or cancel
operation!"
End If
End If
End If
End Sub