change to single form view

  • Thread starter Thread starter Alex Dybenko
  • Start date Start date
I have a form (master form) and sub form

What I want

I want to put a button in a master form to change the view of the subform

from data sheet view to single form view

Something like this?
Let's assume the name of the form used as the subform is "frmDetails",
and that the name of the master form is "frmMaster".
Let's also assume the name of the Record 's Prime Key field is [ID],
and that you wish to return to the current record after switching
views.

Code a command button click event (on the master Form):

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

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

DoCmd.OpenForm "frmMaster"
Forms!frmMaster!ID.SetFocus
DoCmd.FindRecord lngID, acStart, , acSearchAll
DoCmd.Echo True
End Sub
 
I have a form (master form) and sub form

What I want

I want to put a button in a master form to change the view of the subform

from data sheet view to single form view
 
Back
Top