From datasheet to continuous

  • Thread starter Thread starter Neal
  • Start date Start date
N

Neal

Probably a silly question...

I have a subform where I'd like the default view to be datasheet view and I
have a command button which I'd like to use to toggle to continuous forms
view. When I use

Application.RunCommand acCmdSubformDatasheet

it toggles, but from datasheet to regular form view (not continuous). If I
set the default view to continuous, then it properly toggles between
datasheet and continuous. But then it forced me to write some code in
FormOpen to switch from continuous to datasheet before initial display.

What am I missing? Thanks much.
 
Probably a silly question...

I have a subform where I'd like the default view to be datasheet view and I
have a command button which I'd like to use to toggle to continuous forms
view. When I use

Application.RunCommand acCmdSubformDatasheet

it toggles, but from datasheet to regular form view (not continuous). If I
set the default view to continuous, then it properly toggles between
datasheet and continuous. But then it forced me to write some code in
FormOpen to switch from continuous to datasheet before initial display.

What am I missing? Thanks much.

This works for me, with the command button located on the Main Form.
ID is the Main form prime key field
lngID is a variable used to return the focus to the same record.
frmDetails is the name of the form used as the sub form.
frmBilling is the name of the Main form.

Private Sub CommandName_Click()
Dim lngID As Long
lngID = Me.ID
DoCmd.Echo False
DoCmd.OpenForm "frmDetails", acDesign, , , , acHidden

If Forms!frmDetails.DefaultView = 1 Then
Forms!frmDetails.DefaultView = 2 '
Else
Forms!frmDetails.DefaultView = 1
End If
DoCmd.Close acForm, "frmDetails", acSaveYes

DoCmd.OpenForm "frmBilling"
Forms!frmBilling!ID.SetFocus
DoCmd.FindRecord lngID, acStart, , acSearchAll
DoCmd.Echo True

End Sub
 
Back
Top