Toggle Between Form and Datasheet Views

  • Thread starter Thread starter Bill Foley
  • Start date Start date
B

Bill Foley

Hey Gang,

Access XP - Can't seem to get the right constants to run (from code) the
ability to toggle between datasheet and form view on one of my forms. I had
an old set of commands (based on DoMenuItem for Version 2.0) that used to
work until I upgraded to access XP. Right now, it switches to datasheet
view, but when clicking the command button again it just stays in datasheet
view (doesn't toggle to Form View).

Can anyone provide me the line of code to do this?

TIA!
 
Hi Bill,

Try these:

RunCommand acCmdDatasheetView
RunCommand acCmdFormView

P.S. Say Hi to Jan in PowerPoint-land for me.
 
Thanks, Jeff, but I was looking for the line that is the same syntax as my
previous code. I know these are the new ways instead of the old
"DoMenuItem", but how do I assign this code to "toggle" the view by clicking
a button.

Basically I have a form (where the button lives) and subform and I need to
go to the subform control and toggle it's view. My old code I used to use
was:

Sub ToggleView()
DoCmd.GoToControl "frmMySubForm"
DoCmd.DoMenuItem A_FORMBAR, 2, 3, , A_MENU_VER20
End Sub

This does toggle it from it's normal view (Form View) to datasheet view, but
when clicked again, it does nothing.

TIA! By the way, will tell Jan hi for you!

--
Bill Foley, Microsoft MVP (PowerPoint)
www.pttinc.com

Jeff Conrad said:
Hi Bill,

Try these:

RunCommand acCmdDatasheetView
RunCommand acCmdFormView

P.S. Say Hi to Jan in PowerPoint-land for me.
 
Hi Bill,

I was having a little trouble with this myself so I understand your frustration!
Change the code to this:

Private Sub ToggleView()
Me.frmMySubForm.SetFocus
DoCmd.RunCommand acCmdSubformDatasheet
End Sub

That should do it.
TIA! By the way, will tell Jan Hi for you!

Ok!

--
Jeff Conrad
Access Junkie
Bend, Oregon

Bill Foley said:
Thanks, Jeff, but I was looking for the line that is the same syntax as my
previous code. I know these are the new ways instead of the old
"DoMenuItem", but how do I assign this code to "toggle" the view by clicking
a button.

Basically I have a form (where the button lives) and subform and I need to
go to the subform control and toggle it's view. My old code I used to use
was:

Sub ToggleView()
DoCmd.GoToControl "frmMySubForm"
DoCmd.DoMenuItem A_FORMBAR, 2, 3, , A_MENU_VER20
End Sub

This does toggle it from it's normal view (Form View) to datasheet view, but
when clicked again, it does nothing.

TIA! By the way, will tell Jan hi for you!
 
Back
Top