Results 1 to 12 of 12
  1. #1
    Join Date
    Dec 2003
    Location
    New York
    Posts
    47

    Unanswered: Multiple Link Criteria

    I need to use a link criteria pulling up a report that actually had 2 criteria. Currently I have it written:

    stLinkCriteria = "[ContactID]=" & Me![intContact] And "[MatterID]=" & Me![intMatter]

    It is returning a mistype error.

    In case there is a better way to do it, this is the rest of the code

    stDocName = "rptBlankLetterContact"
    stLinkCriteria = "[ContactID]=" & Me![intContact] And "[MatterID]=" & Me![intMatter]

    [Forms]![frmContacts]![sfrmActivity-Contact].[Form]![intContact] = Forms![frmContacts]![CustID]
    [Forms]![frmContacts]![sfrmActivity-Contact].[Form]![datActivity] = Date
    [Forms]![frmContacts]![sfrmActivity-Contact].[Form]![intMatter] = [intMatter]
    [Forms]![frmContacts]![sfrmActivity-Contact].[Form]![txtType] = "Letter"
    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
    DoCmd.OutputTo acOutputReport, stDocName, acFormatRTF, Forms![frmContacts]![txtLName] & ", " & Forms![frmContacts]![txtFName] & " " & Format(Date, "m-d-yyyy") & ".doc", True
    DoCmd.Close acReport, "stDocName"

    I can get it to work with putting the criteria in the queries but I would end up with dozens of queries and reports if I do it that way and would like to avoid it.

    Thanks
    Terri Gavin

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You never restart the string after the first form reference. Try:

    stLinkCriteria = "[ContactID]=" & Me![intContact] & " And [MatterID]=" & Me![intMatter]
    Paul

  3. #3
    Join Date
    Dec 2003
    Location
    New York
    Posts
    47
    Paul, thank you! It worked and I learned something new in my quest to learn 'code on the go'.
    Terri Gavin

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Happy to help Terri.
    Paul

  5. #5
    Join Date
    Aug 2013
    Posts
    9

    Multiple link criteria

    Hi, i've got the same problem but the solution wont do. Have you an another suggestion. I'm not use to VB and not so good in english to, sorry for that.

    Here's my original string:
    stLinkCriteria = "[Section]=" & "'" & Me![Section] & "'" And "[Site]=" & "'" & Me![SITE]
    Cause a mistype error, tryed yours :
    stLinkCriteria = "[Section]=" & Me![Section] & " And [site]=" & Me![SITE]
    cause a Syntax error, (missing operator) in expression.

    Any suggestion?

    Quote Originally Posted by pbaldy View Post
    You never restart the string after the first form reference. Try:

    stLinkCriteria = "[ContactID]=" & Me![intContact] & " And [MatterID]=" & Me![intMatter]

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Different data types require delimiters.

    Open a second form to the record
    Paul

  7. #7
    Join Date
    Aug 2013
    Posts
    9
    First thanks for the fast reply. This other method work with one criteria But it still won't work with multiple criteria. Has tgavin's problem, the first form is use only to choose what to show on the second one. witch is a form base on a cross analysis query. Why condition "and" wont work?

    Quote Originally Posted by pbaldy View Post
    Different data types require delimiters.

    Open a second form to the record

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The link was simply to demonstrate that different data types require different delimiters, or none. Since you haven't said what the data types of your 2 fields are, it's hard to do say why yours isn't working.
    Paul

  9. #9
    Join Date
    Aug 2013
    Posts
    9
    Hi pbaldy, the data type is text, the delimiters seem ok cause they work seperately when use as a single condition. The problem occur when both are use wtih an "and"

  10. #10
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The syntax in your first one is wrong. Try

    stLinkCriteria = "[Section]='" & Me![Section] & "' And [Site]='" & Me![SITE] & "'"
    Paul

  11. #11
    Join Date
    Aug 2013
    Posts
    9
    It work!!!!! You are a machine! , but i don't understand.... a chance we have cut and paste option. Has i said i'm not use to VB, i've learn Access on my own and please when i can leran something. Have you a "Baldy" web seminar or another web link that simply explain the basic of VB language? Thank you a lot, you've make my day.

  12. #12
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Happy to help!
    Paul

Posting Permissions

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