Dlookup Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have put and event function on the Lost Focus of one of my fields in a form
and it will not work. The following is the code:
Private Sub CustomerNumber_LostFocus()
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber='" &
[CustomerNumber] & "'")

End Sub

When I hit the tab button I get a Run-time error '3464'

I have looked up the error and I can't figure out what the problem is.
The tblClients.CustomerNumber is an auto number type and the forms
[CustomerNumber] is a number type.

Your help is greatly appreciated.
Thanks,
Curt Hand
 
Ditch some of the quotes:
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber] )
 
Thanks Duane you are always a great help. It works great.

Duane Hookom said:
Ditch some of the quotes:
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber=" &
[CustomerNumber] )

--
Duane Hookom
MS Access MVP
--

Curt Hand said:
I have put and event function on the Lost Focus of one of my fields in a
form
and it will not work. The following is the code:
Private Sub CustomerNumber_LostFocus()
ClientName = DLookup("CompanyName", "tblClients", "CustomerNumber='" &
[CustomerNumber] & "'")

End Sub

When I hit the tab button I get a Run-time error '3464'

I have looked up the error and I can't figure out what the problem is.
The tblClients.CustomerNumber is an auto number type and the forms
[CustomerNumber] is a number type.

Your help is greatly appreciated.
Thanks,
Curt Hand
 
Back
Top