Results 1 to 7 of 7
  1. #1
    newbie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    34

    Question Command Buttons Only Work If DB Opened In Design View Then Form View


    I have what is to me a very odd situation. I have a DB that I set up almost a year ago with command buttons that open reports. About 2 weeks ago I added a new report and command button. Ever since then my existing command buttons have gone haywire. I open my DB in form view. If I select any command button I get a "The Expression On Click you entered as the event property setting produce the following error: Return on GoSub". If I go to design view / Command Properties / Event Tab / Open the Visual Basics window, make no changes just immediatley close the window and put my DB back into form view the command buttons work. Why am I having to do this little jog? It is very annoying.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    If you continue adding reports, you may try putting them in a list and let user pick one. Some even need a time range, etc. (see photo)
    Click image for larger version. 

Name:	reports.png 
Views:	8 
Size:	15.5 KB 
ID:	16404

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    also..to the problem...the only code needed to print is Docmd.openreport "rptName" , acViewPreview.
    All the auto generated code isnt really needed.

  5. #5
    newbie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    34
    I wish I could provide the DB for review but by the time I remove all the PHI there wouldn't be much left to look at. As to the suggestion of the list, this is kind of what I am doing. I just have a form that provides all the lists available. I used command buttons because there is additional text telling the user what the report is, what details it will provide, etc. that doesn't fit in the list. Also, I create the command buttons without the wizard so I don't get all the extra coded.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You can remove embedded macros from Command Button and replace it with code example in post 4. You can also add additional code to manage a MsgBox or whatever else you want.

  7. #7
    newbie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    34
    Thanks for all the replies but I figured out what was causing the strange occurance of this error. There was a random "Got Focus" event that got set on one of my buttons that only had the Private Sub End Sub code and nothing else. I deleted that and now all my command buttons are back to normal.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-09-2014, 03:21 PM
  2. Replies: 6
    Last Post: 03-08-2014, 12:47 PM
  3. Replies: 2
    Last Post: 01-28-2014, 10:13 PM
  4. Replies: 5
    Last Post: 12-03-2013, 01:25 PM
  5. Replies: 8
    Last Post: 04-29-2013, 11:23 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