change to single form view

F

fredg

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
 
A

a

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top