If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Open a second form that is related to the first form
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 |
#2
|
|||
|
|||
Open a second form that is related to the first form
"Debbie" wrote: 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).AllowAdditi ons = 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.RecordS ource = (strRecordsource) Forms(strmainform)(strSubformcontrol).Form.AllowAd ditions = True On Error Resume Next Forms(strmainform)(strSubformcontrol).LinkMasterFi elds = strMasterFields On Error Resume Next Forms(strmainform)(strSubformcontrol).LinkChildFie lds = strChildFields End Function |
Thread Tools | |
Display Modes | |
|
|