Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Oct 2002
    Location
    Sayre, Pennsylvania, USA
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    More VBA Syntax Help (2000)

    Hi,
    I have the following code:
    stLinkCriteria = "[lngMachineID]=" & Me![cboDPLLookup] & _
    " AND [lngVendorID]=" & Me![cboPRVendorSelect]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    I need to replace the lngMachineID which is a number field to txtPRNo which is a text field and get rid of the second line.

    stLinkCriteria = "[txtPRNo]=' " & Me![txtPRNo] " ' "
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Am I missing anything?
    Thanks,
    Deb

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: More VBA Syntax Help (2000)

    The line

    <code>stLinkCriteria = "[txtPRNo]=' " & Me![txtPRNo] " ' "</code>

    misses an ampersand between Me![txtPRNo] and the string after it, and there shouldn't be superfluous spaces between the single quotes:

    <code>stLinkCriteria = "[txtPRNo]='" & Me![txtPRNo] & "'"</code>

    You can also concatenate with Chr(34) (the code for a double quote ") instead of using single quotes:

    <code>stLinkCriteria = "[txtPRNo]=" Chr(34) & Me![txtPRNo] & Chr(34)</code>

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: More VBA Syntax Help (2000)

    I believe you've missed a necessary concatenation operator. Try this:
    <font color=blue>
    stLinkCriteria = "[txtPRNo]=' " & Me![txtPRNo] & " ' "
    </font color=blue>
    Wendell

  4. #4
    4 Star Lounger
    Join Date
    Oct 2002
    Location
    Sayre, Pennsylvania, USA
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: More VBA Syntax Help (2000)

    Hans & Wendell,
    Thank you very much. That did it.
    Deb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •