Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011
    Posts
    1

    Unanswered: Access DoCmd OpenReport - parameter not used in preview

    Hi,
    I'm using Access 2010 and have a problem when I want to preview a report.

    I want to open a report with customerdata using a parameter "Factuur plaats" (=city) to view all customers who are located in that city.

    I added an option menu and a button on the switchboard. A user chooses a city from the option menu and then clicks the button.
    The parameter goes through as CboNaamPlaats. Reportname is "qPlaatsNaam".

    The following code works:
    Private Sub Button35_Click()
    On Error GoTo Err_Button35_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "qPlaatsnaam"

    stLinkCriteria = "[Factuur plaats]=" & "'" & Me![CboNaamPlaats] & "'"
    DoCmd.OpenReport stDocName, , , stLinkCriteria

    Exit_Button35_Click:
    Exit Sub

    Err_Button35_Click:
    MsgBox Err.Description
    Resume Exit_Button35_Click

    End Sub

    This prints out the report using the parameter.

    However I'd like to have a print preview before we print out the report. Problem is that when I use the following code, I still get a box asking for a parameter.

    Private Sub Button35_Click()
    On Error GoTo Err_Button35_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "qPlaatsnaam"

    stLinkCriteria = "[Factuur plaats]=" & "'" & Me![CboNaamPlaats] & "'"
    DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

    Exit_Button35_Click:
    Exit Sub

    Err_Button35_Click:
    MsgBox Err.Description
    Resume Exit_Button35_Click

    End Sub

    Any thoughts? Thanks in advance!
    Cindy

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183
    Check whether the control names on the Form, Report or in the Query of the Report data source is not mis-spelled. You have created some expression in a Textbox to take Summary or count etc. on the Report is misspelled. You have created an expression earlier but later on changed the control name appearing in the expression, without knowing that it is part of a formula. Look through carefully you will find it.
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

Posting Permissions

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