Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    It looks like in Northwind they set a variable in the report code to make sure it's open. For now, comment out or delete this line and see what happens:

    If Not Reports![HarvestingSummary].blnOpening Then Err.Raise 0



    It's forcing an error and throwing you into the error handler, where that message is.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #17
    jparker1954 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    85
    OK, we're getting closer now. Everything seems to work except the cancel button. How do I "trap for the error that will happen if you click the cancel button."

    Here's the code now:

    Private Sub Cancel_Click()
    ' This code created by Command Button Wizard.
    On Error GoTo Err_Cancel_Click
    ' Close form.
    DoCmd.Close
    Exit_Cancel_Click:
    Exit Sub
    Err_Cancel_Click:
    MsgBox Err.Description
    Resume Exit_Cancel_Click
    Private Sub OK_Click()
    On Error GoTo Err_OK_Click
    Dim strMsg As String, strTitle As String
    Dim intStyle As Integer

    ' Hide form.
    Me.Visible = False
    Exit_OK_Click:
    Exit Sub
    Err_OK_Click:
    strMsg = "To use this form, you must preview or print the report from the Database window or Design view."
    intStyle = vbOKOnly
    strTitle = "Open from Report"
    MsgBox strMsg, intStyle, strTitle
    Resume Exit_OK_Click
    End Sub

  3. #18
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You can trap for the error or avoid it. When you click the cancel button, you're closing the criteria form. That means the criteria will not be available for the report's query, and it will error. Actually it probably throw a parameter prompt. What I would probably do is test to see if the form is open in the next line after the OpenForm. If it's not, set

    Cancel = True

    to stop the report from loading. Search on IsLoaded for a method to test for the form being open.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #19
    jparker1954 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    85
    Unfortunately, now, after working several times without a problem, it appears that the
    [Forms]![myForm]![myControl] OR [Forms]![myForm]![myControl] Is Null command has decided that if the controls are Null, then it won't print anything on the report. Previously it printed the entire report as it should have. I made no changes to the controls to cause this. It just worked one time, then didn't work the next.

  5. #20
    jparker1954 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    85
    With Regard to the Cancel button throwing a parameter prompt, that is exactly what it is doing.

  6. #21
    jparker1954 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    85
    Eureka! It's finally done and working! I found the code for the IsLoaded method, the forms are loading properly, reports are printing correctly and I am very grateful for all your help and patience. I've learned a great deal and will be using this information a lot in the future. Thanks!

  7. #22
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Outstanding! Glad we got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filter By Date In Different Fields
    By Douglasrac in forum Queries
    Replies: 13
    Last Post: 03-21-2011, 05:24 PM
  2. Replies: 3
    Last Post: 10-07-2010, 09:36 AM
  3. Dialog box form example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-30-2010, 10:45 PM
  4. Pop-up Dialog Box
    By DianeG in forum Reports
    Replies: 4
    Last Post: 03-29-2010, 09:51 AM
  5. Unwanted Dialog Box
    By ntallman in forum Programming
    Replies: 3
    Last Post: 03-26-2010, 11:11 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