Results 1 to 8 of 8
  1. #1
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22

    Report Won't Print

    I'm hoping someone has seen this problem before and can give me some idea on how to fix. Frustration doesn't describe ...



    I have a pop-up parameter form that allows the user to select from six (6) drop down combo boxes to filter a report (NIFC Report). The form is tied to a parameter query for its records and the OK button on the form (Report Parameters) has the following code:

    Private Sub cmdOK_Click()
    On Error Go To cmdOK_Click_Err

    DoCmd.OpenReport "NIFC Report", acViewReport
    DoCmd.Close acForm,"Report Parameters"

    cmdOK_Click_Exit
    Exit Sub

    cmdOK_Click_Err:
    MsgBox Error$
    Resume cmdOK_Click_Exit

    End Sub

    The form and query work perfectly and the report pops up with exactly the records I need. There is never a problem .. until I try to print the report. Whe I select print or print preview, an access-generated parameter form asks for all six of the parameters again (I already selected my parameters from the form to produce my report ... grrrrrr). Almost anything can happen from this point forward. I simly want to print the report that's on the screen, but (Access) wants to print every record in the database. I have to quickly cancel print to save a tree. Or, it will print in datasheet format, rather than the report format I see on screen. Or, it wants to print the last report I worked with from another Access database.

    It's almost as if Access doesn't recognize the report and/or record set that's just been produced and is on the screen. Is there code that I've failed to include or have I set up my report incorrectly?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Apparently the form would have to remain open. An alternative is to use the WHERE argument of DoCmd.OpenReport (same for OpenForm). This is my preference. I almost never set input parameters in queries. However, 6 criteria would make a rather long WHERE clause but can be done.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    A. Are you referencing the parameters anywhere in the report? Say in the Report Header You have a text box that shows the value for parameter 1. If you use the parameter name [Param1] Then you will be prompted as [Param1] is local to the report. Make sure you include the path to the form Forms!form1!cbo_param1. If that's not it more detail would help.

  4. #4
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22
    Thanks June7 - If the form needs to stay open, can it be minimized or made invisible? Seems like the Where argument would serve me well. Would you happen to have an example of a Where clause appropriate to this situation. I'm learning Access bit by bit and not real comfortable with the language.

  5. #5
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22
    Ray - I'm not referencing the parameters in the report, header or otherwise, other than filtering data with a parameter query. My query parameters reference the form (forms!myform!cboname), as you described. Are there specific details you want me to share? I can send pdf copies of the parameter form, parameter query, and report if you think that would be helpful.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I use only VBA, no macros, so in an event such as a button Click, would have code like:

    DoCmd.OpenReport "reportname", , ,"fieldname1=" & Me.tbxTextbox1 & " AND fieldname2='" & Me.tbxTextbox2 & "' AND fieldname3=#" & Me.tbxTextbox3 & "#"

    That shows example of 3 criteria, formatted for number, text, and date types. Now that the values are obtained from the form, can close it.
    DoCmd.Close

    Showing only the AND operator but could also use OR, LIKE, BETWEEN AND, and parenthesis to control order of operations.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Ok, just wanted to be sure. the issue is that when you click on the Ok button the report runs to the screen and the parameters are picked up from the form. Then you close the form. when you click on print from the preview screen the report is re-generated but since the form has closed you are prompted for the parameters. Move the docmd.close for the form to the close or unload event for the report. That way the form will stay open until you close the report. The only issue you might have is if they minimize the report instead of closing it the form would remain open.

  8. #8
    Two Gun is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    22
    Thanks RayMilhon & June7. Leaving the form open did the trick!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Print a report without saving it
    By maladoi in forum Reports
    Replies: 2
    Last Post: 08-18-2011, 12:07 PM
  2. Replies: 0
    Last Post: 02-22-2011, 05:04 AM
  3. Can't see sub report in print preview
    By LoggyDoggy in forum Access
    Replies: 1
    Last Post: 04-20-2010, 05:38 PM
  4. Print Report from Form ID
    By Brian62 in forum Forms
    Replies: 1
    Last Post: 09-18-2009, 01:50 PM
  5. Replies: 3
    Last Post: 03-24-2006, 08:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums