Dropdown Box DLookup Error (1 Viewer)

Learn2010

Registered User.
Local time
Yesterday, 23:34
Joined
Sep 15, 2010
Messages
415
I use this same format elsewhere in other databases and it works.

START OF CODE
InvoiceAmount = DLookup("InvoiceAmount", "tblInvoices", "[Invoice] = '" & Me.Invoice & "'")
END OF CODE

Here, it doesn’t work. I have tried this with a query and a table as the RecordSource of the form. Here, I have a form with a dropdown box on it. The ControlSource of the dropdown box is OrgID. When clicked, the dropdown displays the seven fields listed via a query. OrgID is there but doesn’t display because the width is zero. It is the bound column. In the AfterUpdate property I have the following:

START OF CODE
ReleaseTo = DLookup("ReleaseTo", "tblDropROI", "OrgID = '" & Me.OrgID & "'")
Address = DLookup("Address", "tblDropROI", "OrgID = '" & Me.OrgID & "'")
City = DLookup("City", "tblDropROI", "OrgID = '" & Me.OrgID & "'")
State = DLookup("State", "tblDropROI", "OrgI = '" & Me.OrgID & "'")
ZipCode = DLookup("ZipCode", "tblDropROI", "OrgID = '" & Me.OrgID & "'")
Telephone = DLookup("Telephone", "tblDropROI", "OrgID = '" & Me.OrgID & "'")
END OF CODE

The fields on the form match exactly the fields on table tblDropROI. When the selection is made, I get a runtime error 3464, “Data type mismatch in criteria expression.” I also tried it with brackets around OrgID like the code below and get the same results.

START OF CODE
ReleaseTo = DLookup("ReleaseTo", "tblDropROI", "[OrgID] = '" & Me.OrgID & "'")
END OF CODE

Any suggestions?

Thank you.
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:34
Joined
Jul 2, 2005
Messages
13,826
This probably runs pretty slow with all of those Domain functions. If the RowSource of the ComboBox is "tblDropROI" there is a much faster way to get the values. If "OrgID" is a number then your code should be: "[OrgID] = " & Me.OrgID )
 

Learn2010

Registered User.
Local time
Yesterday, 23:34
Joined
Sep 15, 2010
Messages
415
I tried that and it doesn't work. I get the same error message.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:34
Joined
May 7, 2009
Messages
19,243
If OrgID is Numeric, you must remove the extra single Quote on your Criteria:


"[OrgID]=" & Me.[OrgID]
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:34
Joined
Jul 2, 2005
Messages
13,826
Did you want to mark this thread as Solved?
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:34
Joined
Jul 2, 2005
Messages
13,826
It should be under "Thread Tools" at the top of the thread. I believe it is only available to the OP of the thread and the Mods of course.
 

Users who are viewing this thread

Top Bottom