[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 741
  • Last Modified:

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

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

Example:
  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

Ldufresne
0
Lou Dufresne
Asked:
Lou Dufresne
1 Solution
 
BitsqueezerCommented:
Hi,

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:

http://msdn.microsoft.com/en-us/library/office/ff834753%28v=office.15%29.aspx

Cheers,

Christian
0
 
Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Perfect. Now I know hoe to use setup and use this code.

Thanks.

Ldufressne
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now