RunTime error: 3075 - Dlookup Issue (1 Viewer)

Adigga1

Registered User.
Local time
Today, 09:16
Joined
Oct 2, 2008
Messages
57
Hello Experts,

I'm about to go grey with this dlookup statement:

I'm trying to run a dlookup statement, I have the correct expression string, etc. but when I run it under the Immediate window for testing I'm getting the runtime error.

Scanerio:

I'm calling an associated Price value (Currency) for a Code (text) from a Query in order to have an auto population in the fields; here is the code:


Code:
 Private Sub CPTcode_AfterUpdate()
Code:
[SIZE=3][FONT=Times New Roman]  Charge = DLookup("Charge", "Q_CPT-phys test1", "CPTcode= '& CPTcode'")[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]End Sub [/FONT][/SIZE]

It only populates if i replace the & CPTcode with an actual value. This is pulling from the same Subform. Immediate window for testing I'm getting the runtime error.

Scanerio:

I'm calling an associated Price value (Currency) for a Code (text) from a Query in order to have an auto population in the fields here is the code:



Please Help

Adigga1
 

RuralGuy

AWF VIP
Local time
Today, 07:16
Joined
Jul 2, 2005
Messages
13,826
Try:
Charge = DLookup("Charge", "[Q_CPT-phys test1]", "CPTcode= ' " & CPTcode " ' ")
...if it is a string value. (Extra spaces added for visibility)
 

Adigga1

Registered User.
Local time
Today, 09:16
Joined
Oct 2, 2008
Messages
57
Try:
Charge = DLookup("Charge", "[Q_CPT-phys test1]", "CPTcode= ' " & CPTcode " ' ")
...if it is a string value. (Extra spaces added for visibility)


Thank you for your suggestion; I will try this code and follow-up with the results.

Adigga1
 

Adigga1

Registered User.
Local time
Today, 09:16
Joined
Oct 2, 2008
Messages
57
RG,

When I ran the code I got the Compile error: message; it states: "Expected: list separator or )".


Adigga1
 

Kiwiman

Registered User
Local time
Today, 14:16
Joined
Apr 27, 2008
Messages
799
Hoiwzit

A missing & sign in rurals suggestion

if CPTcode a string try

Code:
Charge = DLookup("Charge", "[Q_CPT-phys test1]", "CPTcode= '" & CPTcode & "'")

if CPTCode a number try

Code:
Charge = DLookup("Charge", "[Q_CPT-phys test1]", "CPTcode= " & CPTcode)
 

Adigga1

Registered User.
Local time
Today, 09:16
Joined
Oct 2, 2008
Messages
57
Thank you soooo much for your patience with me guys, it compiled and ran successfully.

Again, thank you for your assisstance with this issue

Adigga1
 

Users who are viewing this thread

Top Bottom