Link to home
Start Free TrialLog in
Avatar of Lou Dufresne
Lou DufresneFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Bitsqueezer
Bitsqueezer
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lou Dufresne

ASKER

Perfect. Now I know hoe to use setup and use this code.

Thanks.

Ldufressne