RunTime error: 3075 - Dlookup Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adigga1
    New Member
    • Feb 2008
    • 29

    RunTime error: 3075 - Dlookup Issue

    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()
        Charge = DLookup("Charge", "Q_CPT-phys test1", "CPTcode= '& CPTcode'")
    End Sub
    It only populates if i replace the "& CPTcode" with an actual value. This is pulling from the same Subform.

    Please Help

    Adigga1
  • mandanarchi
    New Member
    • Sep 2008
    • 90

    #2
    Try this instead.

    Code:
    Charge = DLookup("Charge", "Q_CPT-phys test1", "CPTcode= '" & CPTcode & "'")
    I have issues with DLookups too, it's not just you =)

    Comment

    • adigga1
      New Member
      • Feb 2008
      • 29

      #3
      mandanarchi,


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

      Adigga1


      It ran Successfully!! Thank you
      Last edited by adigga1; Nov 14 '08, 12:56 PM. Reason: Success!!!

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Is CPTcode a Text or Numeric Datatype? The syntax varies accordingly.

        For Numeric CPTcode:
        Code:
        Me.Charge = DLookup("Charge", "Q_CPT-phys test1", "CPTcode= "& Me.CPTcode)
        For Text CPTcode:
        Code:
        Me.Charge = DLookup("Charge", "Q_CPT-phys test1", "CPTcode = '" & Me.CPTcode & "'")
        Welcome to Bytes!

        Linq ;0)>

        Comment

        Working...