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
LVL 1
Lou DufresneIT Business Analyst CSM / Project ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Perfect. Now I know hoe to use setup and use this code.

Thanks.

Ldufressne
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.