Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    6

    Unanswered: How to change view via VB

    I would like to create a button that changes between form and datasheet views. I have done some searching, but can't locate any VB code that achieves this. Any help would be appreciated.

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,475
    Provided Answers: 11
    Just Try

    DoCmd.OpenForm "MyForm", acFormDS, "", "", , acNormal

    One thing i alway

    if I can't think of the code

    I build the Macro to do the job

    and then get access to convert it to vb for me.

    that how i leant to write VB
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Follow myle's suggested code.

    And if you want to switch between Form view and Data Sheet view on the fly then do the following:

    Create a Command button on your Form. In the OnClick event of this button enter the following code:

    'Switch to Data Sheet view.
    DoCmd.OpenForm "myFormName", acFormDS


    Now in the OnClick event of your Form enter this code line:

    'Switch to Form view.
    If Screen.PreviousControl.Name = "myCommandButtonName" Then
    DoCmd.OpenForm "myFormName"
    End If

    If you intend to work (enter or change data) in Data Sheet view then get rid of the If/End If statement.



Posting Permissions

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