MS Access 2013 - form VBA to toggle between Datasheet and Form View

Posted on 2014-08-26
Last Modified: 2014-08-27
I am working in MS access 2013 and need VBA code that will allow me to determine if the subform that I am on is a datasheet or a form.

What I am trying to do is allow the user to click on the subform field "Reporting_Year" and have the subform switches to  a subform datasheet and then when the user clicks on the same subform field  "Reporting_Year the subform switches from a subform back to a datasheet.

The main Form is titled:  F-100-00 StartUpMain
The Subform is titled: F-100-01 CFR_Pivot -All Records

  Private Sub REPORTING_YEAR_DblClick(Cancel As Integer)
     If Form.subform is a datasheet then
         DoCmd.RunCommand acCmdSubformFormView
     else if
         Form.subform is SubformFormView  then
         DoCmd.RunCommand acCmdSubformDatasheetView
   end if
End Sub

Any assistance will be  appreciated

Question by:Lou Dufresne
    LVL 24

    Accepted Solution


    you can do that with the "CurrentView" property of the form. Details about that and how to use it (including demo code) you can find here:


    LVL 1

    Author Closing Comment

    by:Lou Dufresne
    Perfect. Now I know hoe to use setup and use this code.



    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
    Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now