Button to open form in Continuous Forms View

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

Guest

I know that the DoCmd OpenForm overrides the form's own default view. But
how do I specify "Continuous Forms View" ?

Thanks.
 
r. howell said:
I know that the DoCmd OpenForm overrides the form's own default view. But
how do I specify "Continuous Forms View" ?

Thanks.


The second argument is the form view; specify acFormDS for Datasheet view.

DoCmd.OpenForm stDocName, acFormDS

HTH
 
I know that the DoCmd OpenForm overrides the form's own default view. But
how do I specify "Continuous Forms View" ?

Thanks.

If the Form's Default View is continuous it will open in continuous.

If the Default View is single and you wish it to open in continuous
view instead, code a command button on another form:

DoCmd.OpenForm "FormName", acDesign, , , , acHidden
Forms!FormName.DefaultView = 1
DoCmd.OpenForm "FormName"

When you close the form you will be asked whether of not to save the
default view change.

Or perhaps you meant opening the form in Datasheet view.
DoCmd.OpenForm "FormName", acFormDS
 
Hi.
how do I specify "Continuous Forms View" ?

One cannot use the OpenForm method to change the view to Continuous Forms
View. The only way to change it at run time is to open the form in Design
View, change the Default View Property to Continuous Forms, then open the
form again. The downside is that the user will be prompted to save changes
when the form is closed.

Private Sub OpenFormBtn_Click()

On Error GoTo ErrHandler

Dim frm As Form
Dim frmName As String

frmName = "frmMyForm"
DoCmd.OpenForm frmName, acDesign
Set frm = Forms(frmName)
frm.DefaultView = acDefViewContinuous
DoCmd.OpenForm frmName

CleanUp:

Set frm = Nothing

Exit Sub

ErrHandler:

MsgBox "Error in OpenFormBtn_Click( ) in " & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & "Error #" & _
Err.Number & vbCrLf & vbCrLf & Err.Description

Err.Clear
GoTo CleanUp

End Sub

However, one may keep the form's default view as continuous forms, yet open
it elsewhere in VBA code with the appropriate view argument, such as
acFormDS, acFormPivotChart, or acFormPivotTable (if using a later version of
Access). So, if one opens a continuous form in Datasheet View with VBA,
there will be no prompt when the form closes:

DoCmd.OpenForm frmName, acFormDS

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
See http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top