Results 1 to 6 of 6
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    The OpenReport action was cancelled

    This message is the result of clicking an Open Report button and gives no clue what the problem is.

    "The On Open event produced the follow error:
    The expression may not result in the name of a macro, funtion or event procedure.



    I'll save you the gory details, but I have to comment out the code in On Open and On Format before the report will open. I also get a less fatal error with the on load event, but the report still opens. Of course commenting that out eliminate all the errors except I lose functionality in the report.

    Here's the catch. This report usually opens without a hitch. Once or twice a week this problem crops up and is always cured by doing a compact and repair. Today this is not fixing the problem. What's more this does not happen on my coworker's computer.

    I can probably hack my way through this, but I'm concerned about the underlying problem. Oh yeah, here the "offending" code. It's pretty tame stuff

    Code:
    Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)
    If Me.Submission_Type_ID = 7 Or Submission_Type_ID = 8 Then
    Me.txtStatus_Date.Visible = False
    Me.txtStatus_Type.Visible = False
    Else
    Me.txtStatus_Date.Visible = True
    Me.txtStatus_Type.Visible = True
    End If
    End Sub
     
    Private Sub Report_Load()
    If IsNull(Form_frmReports.cboCompany) Then
    Me.Filter = ""
    Else
    Me.Filter = "Company_ID = " & Form_frmReports.cboCompany
    Me.FilterOn = True
    End If
    End Sub
     
    Private Sub Report_Open(Cancel As Integer) 
    DoCmd.Maximize
    End Sub

  2. #2
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    Try this:

    Private Sub Report_Load()
    If IsNull(Forms!frmReports!cboCompany) Then
    Me.Filter = ""
    Else
    Me.Filter = "Company_ID = " & Forms!frmReports!cboCompany
    Me.FilterOn = True
    End If
    End Sub

    If that doesn't work, try a decompile and/or Access repair/resinstall. For more information on these, please see http://peterssoftware.com/t_fixerr.htm

  3. #3
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    I don't see any difference between your code and mine.

    Also, FYI, I imported a backup copy of my report which work's perfectly, for now.
    Last edited by Paul H; 11-10-2011 at 03:53 PM. Reason: typo

  4. #4
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    The difference is

    Forms!frmReports!cboCompany

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by Paul H View Post
    I don't see any difference between your code and mine.

    Also, FYI, I imported a backup copy of my report which work's perfectly, for now.
    Do NOT use the syntax Form_FormNameHere.ControlName

    Use the Forms collection - Forms!FormNameHere.ControlName

    using Form_FormNameHere is potentially bad and can cause some nasty side-effects.

  6. #6
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Ah, old people eyes at work.

    Thank you, Peter and thank you Bob for the explanation. I never knew that it mattered. I'll let you know when I get it sorted out.

    Paul
    Last edited by Paul H; 11-14-2011 at 08:09 AM. Reason: grammar

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

Similar Threads

  1. Replies: 15
    Last Post: 07-26-2012, 02:06 PM
  2. OpenReport cancelled
    By wharting in forum Reports
    Replies: 15
    Last Post: 11-11-2011, 02:34 PM
  3. Table NOT TO update if SendObject cancelled
    By Hello World in forum Forms
    Replies: 1
    Last Post: 10-14-2011, 09:41 AM
  4. OpenReport function
    By grad2009 in forum Access
    Replies: 8
    Last Post: 05-22-2010, 10:43 AM
  5. Replies: 2
    Last Post: 11-02-2009, 10:14 PM

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