A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Open a second form that is related to the first form



 
 
Thread Tools Display Modes
  #1  
Old December 1st, 2007, 03:24 AM posted to microsoft.public.access.forms
Debbie[_3_]
external usenet poster
 
Posts: 46
Default 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  
Old December 2nd, 2007, 08:15 AM posted to microsoft.public.access.forms
Bernie
external usenet poster
 
Posts: 125
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:56 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.