Open a second form that is related to the first form

D

Debbie

I have 2 forms. I am trying to synchronize two forms with the proper
ownership (Parent and child). What I am trying to do is to be in one
parent form and while in that form, open the second form (child form)
so that it goes to the related form. In this case the child of the
parent, which is connected by Field Name: Child Acct#. It works
great, except when I get in to the child form, I have to click the
next record, then click the previous button, then the appropriate
child's form is displayed. What am i doing wrong? Can anyone help?
Below is what I have so far. Thanks in advance
Private Sub Command129_Click()
On Error GoTo Err_Command129_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CHILDACCT#"

stLinkCriteria = "[Child Acct#]=" & "'" & Me![Chilld Acct#] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command129_Click:
Exit Sub

Err_Command129_Click:
MsgBox Err.Description
Resume Exit_Command129_Click

End Sub
 
B

Bernie

Debbie said:
I have 2 forms. I am trying to synchronize two forms with the proper
ownership (Parent and child). What I am trying to do is to be in one
parent form and while in that form, open the second form (child form)
so that it goes to the related form. In this case the child of the
parent, which is connected by Field Name: Child Acct#. It works
great, except when I get in to the child form, I have to click the
next record, then click the previous button, then the appropriate
child's form is displayed. What am i doing wrong? Can anyone help?
Below is what I have so far. Thanks in advance
Private Sub Command129_Click()
On Error GoTo Err_Command129_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "CHILDACCT#"

stLinkCriteria = "[Child Acct#]=" & "'" & Me![Chilld Acct#] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command129_Click:
Exit Sub

Err_Command129_Click:
MsgBox Err.Description
Resume Exit_Command129_Click

End Sub



Try this one:

Private Sub Trip_Click()

strmainform = Me.Form.Name
strSubformcontrol = "varform"
strControlname = "frmhistory"
strChildFields = "tabTripHeaderID"
strMasterFields = "tabTripHeaderID"
strRecordsource = "qryTrip"

Call MainFormLoaded(Me.Form.Name)

If MainFormLoad = True Then

Call displayVarform(strmainform, strSubformcontrol, strControlname,
strChildFields, strMasterFields, strRecordsource)
Call bindvarform(strmainform, strSubformcontrol)

Else

strChildFields = ""
strMasterFields = ""
strRecordsource = ""

Call displayVarform(strmainform, strSubformcontrol, strControlname,
strChildFields, strMasterFields, strRecordsource)
Call unboundvarform(strmainform, strSubformcontrol)

End If

Call CalcTotalWeight(strmainform, strSubformcontrol)

'Call varFormEdit(strMainForm, strSubformControl, strControlName, frmState)
'Forms(strMainForm)(strSubformControl).AllowAdditions = False
End Sub




Public Function displayVarform(strmainform, strSubformcontrol,
strControlname, strChildFields, strMasterFields, strRecordsource)

Call bindvarform(strmainform, strSubformcontrol)
Forms(strmainform)(strSubformcontrol).SourceObject = (strControlname)
Forms(strmainform)(strSubformcontrol).Form.RecordSource = (strRecordsource)

Forms(strmainform)(strSubformcontrol).Form.AllowAdditions = True

On Error Resume Next
Forms(strmainform)(strSubformcontrol).LinkMasterFields = strMasterFields
On Error Resume Next
Forms(strmainform)(strSubformcontrol).LinkChildFields = strChildFields

End Function
 

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