Changing form's defaultview in VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I change a form's defaultview with VB? I've tried the following and
get a message telling me to go to Design view.

Me.Defaultview=2
me.Defaultview=Datasheet
Forms!MyForm.Defaultview = 2
 
Why do you want to change the default view of a form in code?

If you have the form open, you will have to switch it to design view

Try the followiing untested code

Docmd.OpenForm Me.Name, acDesign
Me.DefaultView = 2
DoCmd.OpenForm Me.Name, acNormal

But why not just use the following to open the form in datasheet view.
DoCmd.OpenForm "MyForm", acFormDS
 
Back
Top