Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Arkansas, USA
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing the subform view (Access 2000)

    I have a main form that has a subform named subformData. I am trying to put a command button on the main form frmMain that will toggle the subform back and forth between datasheet view and form view. I can't seem to find the right VBA to reference this and make the command button toggle back and forth.

    Any assistance is appreciated.

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Changing the subform view (Access 2000)

    Here is code for the On Click event procedure of the command button:

    Me.subformData.SetFocus
    RunCommand acCmdSubformDatasheet

    Note: you must use the name of the subform as a control on the main form; this is not necessarily the same as the name it has in the database window.

    If you want the button to stay down when datasheet view is selected, use a toggle button instead of a command button. If the user can change the view from the menu, the state of the toggle button won't be synchronized with the view any more.

  3. #3
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Arkansas, USA
    Posts
    163
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing the subform view (Access 2000)

    Worked perfectly, as usual your advice is priceless. (I was failing to set focus to the subform prior to trying to run the command.)

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •