[AccessD] Force a form to open in datasheet mode

Stuart McLachlan stuart at lexacorp.com.pg
Fri Feb 15 23:27:35 CST 2013


If you are using the old Switchboard which does a default, Docmd.Openform then you will 
probably have to use a kludge like this:

Private Sub Form_Open(Cancel As Integer)
 Dim str As String
    If Me.CurrentView <> 2 Then
        'if not opened as a datasheet, close and re-open in datasheet view
        str = Me.Name
        DoCmd.Close acForm, str
        DoCmd.OpenForm str, acFormDS
        Exit Sub
    End If
End Sub



On 16 Feb 2013 at 0:05, Arthur Fuller wrote:

> Is there a command that I could use from within the form's code, such as in
> the Load or Open event, to force the form into DataSheet view? I've tried a
> couple of things but so far haven't got the right one.
> 
> TIA,
> Arthur
> 
> 
> On Fri, Feb 15, 2013 at 6:39 PM, Stuart McLachlan <stuart at lexacorp.com.pg>wrote:
> 
> > The default acViewMode  for the VBA command DoCmd.OpenForm is acNormal.
> >
> > Try Docmd.OpenForm "frmMyForm",acFormDS
> >
> > --
> > Stuart
> >
> > On 15 Feb 2013 at 18:15, Arthur Fuller wrote:
> >
> > > I forget how to force a form to open in datasheet mode. The default view
> > is
> > > already set to datasheet and the other views have all be set to No, but a
> > > simple call to DoCmd.OpenForm still opens it in Form view.
> > >
> > > This occurs only when I invoke the form from the default switchboard. If
> > I
> > > just open the form from the Objects pane it opens correctly. What's the
> > > difference?
> > >
> > > --
> > > Arthur
> > > Cell: 647.710.1314
> > >
> > > Prediction is difficult, especially of the future.
> > >   -- Niels Bohr
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> 
> 
> 
> -- 
> Arthur
> Cell: 647.710.1314
> 
> Prediction is difficult, especially of the future.
>   -- Niels Bohr
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list