Change View of Subform

K

Kristen

Hello,
I want to create a button that will allow the user to
change the view of a subform from single form to datasheet
view. Do you know the macro to create this?

Thank you!
 
D

Dirk Goldgar

Kristen said:
Hello,
I want to create a button that will allow the user to
change the view of a subform from single form to datasheet
view. Do you know the macro to create this?

Thank you!

This code, in a button on the main form, will toggle the subform named
"SubformControlName" between form view and datasheet view:

Private Sub cmdSwitchView_Click()

Me.SubformControlName.SetFocus
Application.RunCommand acCmdSubformDatasheet

End Sub

Note that "SubformControlName" must be the name of the subform *control*
on the main form, which isn't necessarily the same as the name of the
form object it displays.
 

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