Hi everyone, I have a sub that works fine when used with the lost focus event, but when I try and use the same sub with the change event I get the above error.
I've searched the net and found lots of information but none of it that I can use.
I'm sure I'm missing something basic so apologies if it's a schoolboy error!
This all applies to an Acess 2003 form. I'm looking to create an instant search that checks a number entered into a text box against a table to return a name. It works fine when the lost focus event is used but this means the user has to click off to see the outcome of the search. As the Dlookup I'm using is instant it won't slow down the form to run the sub every time there is a key press on this text box.
I'm missing something basic though because just changing the event to change is throwing out syntax errors when previously there weren't any.
Here's the code as it is, thanks for any help:
I've searched the net and found lots of information but none of it that I can use.
I'm sure I'm missing something basic so apologies if it's a schoolboy error!
This all applies to an Acess 2003 form. I'm looking to create an instant search that checks a number entered into a text box against a table to return a name. It works fine when the lost focus event is used but this means the user has to click off to see the outcome of the search. As the Dlookup I'm using is instant it won't slow down the form to run the sub every time there is a key press on this text box.
I'm missing something basic though because just changing the event to change is throwing out syntax errors when previously there weren't any.
Here's the code as it is, thanks for any help:
Code:
Private Sub TxtProxyUser_Change()
OnlyNumbers
If IsNull(Me.TxtProxyUser) Then
Me.TxtProxyName = Null
Else
End If
If Len(Me.TxtProxyUser.Text) > 0 Then
Me.TxtProxyName.Value = Nz(DLookup("Consultant", "TblStaffList", "[Personnel Number]=" & Me.TxtProxyUser), "Not Found")
Else
End If
End Sub
Comment