Error with string syntax...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • imrosie
    New Member
    • May 2007
    • 222

    Error with string syntax...

    Hello,
    I'm getting syntax error with this, does anyone see a glaring problem? I thought it was fine, but the compiler is complaining.
    thanks in advance.

    Private Sub custname_AfterU pdate()
    Me.FilterOn = True
    Me.Filter = "CustomerID =" & custacct
    Me.Requery
    End Sub
  • Stwange
    Recognized Expert New Member
    • Aug 2007
    • 126

    #2
    Originally posted by imrosie
    Hello,
    I'm getting syntax error with this, does anyone see a glaring problem? I thought it was fine, but the compiler is complaining.
    thanks in advance.

    Private Sub custname_AfterU pdate()
    Me.FilterOn = True
    Me.Filter = "CustomerID =" & custacct
    Me.Requery
    End Sub
    Assuming custacct is a number, the compiler might be complaining about a type conversion error (I'm not sure if this language does or not, but it's worth a try).

    Try:
    Me.Filter = "CustomerID =" & CStr(custacct)

    If that fails, tell me where Filter is declared or what it is.

    Comment

    • FishVal
      Recognized Expert Specialist
      • Jun 2007
      • 2656

      #3
      Originally posted by imrosie
      Hello,
      I'm getting syntax error with this, does anyone see a glaring problem? I thought it was fine, but the compiler is complaining.
      thanks in advance.

      Private Sub custname_AfterU pdate()
      Me.FilterOn = True
      Me.Filter = "CustomerID =" & custacct
      Me.Requery
      End Sub
      Hi, Rosie.

      What is custacct? Global variable, form control name?

      Comment

      • imrosie
        New Member
        • May 2007
        • 222

        #4
        Originally posted by FishVal
        Hi, Rosie.

        What is custacct? Global variable, form control name?
        Hi FishVal,

        custacct is a form control name.thanks

        Rosie

        Comment

        • FishVal
          Recognized Expert Specialist
          • Jun 2007
          • 2656

          #5
          Originally posted by imrosie
          Hi FishVal,

          custacct is a form control name.thanks

          Rosie
          Try to reference it through the form object - Me.custacct or Me!custacct, as you like.

          And, BTW, are you sure control name is not misspelled?
          This case VBA compiler will automatically dim it as Variant or raise an error if you have "Option Explicit" statement in the module header.

          Comment

          • imrosie
            New Member
            • May 2007
            • 222

            #6
            Originally posted by FishVal
            Try to reference it through the form object - Me.custacct or Me!custacct, as you like.

            And, BTW, are you sure control name is not misspelled?
            This case VBA compiler will automatically dim it as Variant or raise an error if you have "Option Explicit" statement in the module header.
            FishVal,,,
            Your observation was right on,,,,somehow I had 'custacct', when it should have been 'custname'..... ..

            Also I added the CStr(custname) as suggested by Stwange...it's working.
            thanks for your help..forgive the mistake.
            Rosie

            Comment

            • FishVal
              Recognized Expert Specialist
              • Jun 2007
              • 2656

              #7
              Originally posted by imrosie
              FishVal,,,
              Your observation was right on,,,,somehow I had 'custacct', when it should have been 'custname'..... ..

              Also I added the CStr(custname) as suggested by Stwange...it's working.
              thanks for your help..forgive the mistake.
              Rosie
              Actually "CStr" is not needed this case, bkz "&" operator unlike "+" concatenates all variable types with string.
              For example try in Immediate window
              ? "qwerty" +1
              ? "qwerty" & 1

              Comment

              • imrosie
                New Member
                • May 2007
                • 222

                #8
                Originally posted by FishVal
                Actually "CStr" is not needed this case, bkz "&" operator unlike "+" concatenates all variable types with string.
                For example try in Immediate window
                ? "qwerty" +1
                ? "qwerty" & 1
                FishVal,

                You're right...thanks so much.
                Rosie

                Comment

                Working...