Toggle Between Form and Datasheet Views

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!
 
J

Jeff Conrad

Hi Bill,

Try these:

RunCommand acCmdDatasheetView
RunCommand acCmdFormView

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

Bill Foley

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.
 
J

Jeff Conrad

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top