Results 1 to 9 of 9
  1. #1
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904

    Cannot Open Form in Datasheet View from Command Button

    I am using Access 2007 and trying to open a Form in Datasheet view via a command button. I have the following code to open it:
    Code:
    Private Sub cmdDefaultElects_Click()
        DoCmd.OpenForm "frm-Default_Election_Amounts", acFormDS
    End Sub
    However, when I click the button, it opens in the default form view (single record at a time) instead of Datasheet view. If I open the Form directly from the Objects menu, it correctly opens in Datasheet view.

    I have even gone into the Properties of the Form and changed the following:
    Default View: Datasheet
    Allow Form View: No
    Allow DataSheet View: Yes

    But it made no difference when trying to open it from my Command Button.

    Any ideas why this is happening, and how I can get my Form to open in Datasheet View when opening from a Command Button?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Cannot replicate the issue. 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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I can't, either, and Properties set in errant Form's Properties Pane has nothing to do with how it opens, using a Command Button, that's why you have to use the Form View Parameter of acFormDS.

    When things that patently should work are found to not work, you simply have to think about corruption! First thing, I'd do, after saying a prayer to the Access Gods (or maybe the Access Gnomes!) would be to delete your current Command Button and re-create it. It's simple enough to do, and would rule out whether or not it is the Command Button Control that is corrupt. CB's cand and do get corrupted, on a regular basis, during development.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    delete your current Command Button and re-create it
    Well, hot dog! That did it! Not sure how a brand new Command Button I just created yesterday got corrupted, but re-creating it did indeed fix the probem. Thanks for the suggestion!

    I am glad that worked, because it would have taken a lot of data scrubbing and deleting to post the database up. Most of the data comes from linked SQL tables, and there is a lot of confidential information in it.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Being in forced retirement, I spend 8-10 hours a day, most days, trolling and contributing to four or five Access forums, and see this problem posted at least once every single day! Actually saw it three times yesterday!

    As I said, it appears to almost always happen during development, never after the app is deployed. No idea why that is!

    Good luck with your project!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Its funny, I create stuff likes this all the time (using Command Buttons and VBA code), and hardly ever have issues with it, so I assumed that I was missing something. I have had Databases get corrupted, but rarely Command Buttons! But then again, we all know how "flaky" Access can be at times. I should have thought to try to rebuild it...

    Thanks for the reminder!

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    This type of thing comes under what I call Strange, Odd and Curious Behavior, and S/O/C/B, when something that patently should work but doesn't work, usually translates into corruption, in one form or another. Don't know why Access is so susceptible to corruption, except that it is such a complex app.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    This type of thing comes under what I call Strange, Odd and Curious Behavior, and S/O/C/B
    Yep, there's not shortage of those things in Access!

    Can't tell you all the fun "differences" we found between Access and SQL when we moved a database from an Access back-end to a SQL back-end!

  9. #9
    STONEE is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Location
    LAKELAND FL
    Posts
    2
    If you are using access 2010 or later, do not use the properties panel, it will only revert to form view.
    Go to the embedded macro viewer and when you open the form, go to the view dropdown and select dataset.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-11-2012, 11:52 AM
  2. Command button open url
    By patrickmcdiver in forum Programming
    Replies: 2
    Last Post: 03-06-2012, 11:08 AM
  3. Replies: 3
    Last Post: 02-23-2012, 04:48 PM
  4. Replies: 4
    Last Post: 12-01-2010, 02:42 PM
  5. Use a command button to open a form
    By johnpaul in forum Forms
    Replies: 24
    Last Post: 09-23-2010, 12:29 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