Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookUp function in a macro

Status
Not open for further replies.

AidanEnos

MIS
Dec 11, 2000
189
Ok,

This should work but doesn't and driving me nuts - not even sure where it's failing!!!

As I understand it, this code says...

I want the CustomerName field from the CustomersTable input to the CustomerName field on the active form and I want the CustomerName from the Entry in the CustomersTable that is in the record I just selected with the cboList box.

(I have it set to after Update on the cboList field)

DLookUp("CustomerName","CustomersTable","CustomerName = " & [cboList])

I know I'm missing some quotes or brackets or soemthing - I've tried a plethera of combinations - now show me the right choice!
 
My Current Macro Syntax is as below

[CustomerName], =DLookUp("CustomerName","CustomersTable","CustomerIdentifier '=" & [cboList] & "'")

I have continued to work on this fruitlessly - but, I have encountered an encouraging error :)

I select a name from the list and I get:

"Syntax Error (missing operator) in query Expression 'CustomerIdentifier'=Mike''

It offers Help - but all the help says is your expression doesn't work now go fix it.

Mike being the customername I selected from the combo box.

 
How are ya AidanEnos . . .

Try this:
Code:
[blue]   Dim Cri As String
   [green]'if CustomerIdentifier is text, use this line[/green]
   Cri = "[CustomerIdentifier] ='" & Me!cboList.Column(0) & "'"
   [green]'if CustomerIdentifier is numeric, use this line[/green]
   Cri = "[CustomerIdentifier] = " & Me!cboList.Column(0)
   CustomerName = DLookup("CustomerName", "CustomersTable", Cri)[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top