Results 1 to 3 of 3
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Select Report Preview (2002 SP-2)

    Code newbie having a bit of a struggle here.
    The following code is bringing up the report in preview, but not according to the link criteria. The link criteria looks right, so I think it must be in the DoCmd line. Little help?
    <pre>Private Sub cmdPreviewQuote_Click()
    On Error GoTo Err_cmdPreviewQuote_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "rptQuote"
    stLinkCriteria = "[ID]=" & Me![ID]
    DoCmd.OpenReport stDocName, , , stLinkCriteria, , acPreview

    Exit_cmdPreviewQuote_Click:
    Exit Sub

    Err_cmdPreviewQuote_Click:
    MsgBox Err.Description
    Resume Exit_cmdPreviewQuote_Click

    End Sub</pre>

    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

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

    Re: Select Report Preview (2002 SP-2)

    If you look up OpenReport in the online help, or in the Object Browser, you will see that the syntax is

    DoCmd.OpenReport ReportName, Optional View As AcView = acViewNormal, Optional FilterName, Optional WhereCondition, Optional WindowMode As AcWindowMode = acWindowNormal, Optional OpenArgs

    In general, there are two ways you can specify the arguments:
    <UL><LI>By name: you can specify the arguments in any order you like, but you must name each of them. Example:

    DoCmd.OpenReport View:=acViewPreview, WhereCondition:="[ID]=" & Me![ID], ReportName:="rptQuote"

    <LI>By position: if you enter the arguments without naming them, you must use the order as in the syntax above. If you omit an argument you must still use a comma (but not at the end, after the last specified argument.) Example:

    DoCmd.OpenReport "rptQuote", acViewPreview, , "[ID]=" & Me![ID][/list]If you compare your instruction to the one above, you will notice that you have some of the arguments in the wrong position. You must use either of the following:

    DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
    DoCmd.OpenReport ReportName:=stDocName, WhereCondition:=stLinkCriteria, View:=acViewPreview

  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Select Report Preview (2002 SP-2)

    Gees, and I thought I was a slow learner!
    You still haven't learned your lesson in not replying to my posts?
    I do weave a tangled web don't I <img src=/S/devil.gif border=0 alt=devil width=15 height=15>

    Thanks again for bailing me out! I was actually closer in my first several attempts, but still had too many or not enough "comma's". I then jumped ship and started playing around with the order - total guesswork. I tried to follow the Access "clues" as I went along typing, but I guess you need to have a clue in order to get one. Thanks again Hans; I'll take this information back to the cave with me.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Posting Permissions

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