Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking subform using command button

Status
Not open for further replies.

slybaby1us

Technical User
Apr 17, 2001
5
US
I'm VERY new to this!
I have a mainform and 2 subforms. The 2 subforms link fine with the mainform and to each other when I drag and drop them but I think it looks very clutterd so I created a command button to open the 2nd subform inside the 1st subform (so you can use the form IF you need it)and I cannot make the subforms link. I have checked properties in every form and everything inside the forms and I can only find the master/child thingy on the mainform and 1st subform? Is what I'm attempting possible???

I'm collecting information on customer feedback.

The mainform is from a Dept information table:
managers names, application, team leader, etc.

The 1st subform is a table containing ratings from a survey for different indicators: application performance, project delivery..., who the customer is, etc.

The 2nd subform is an Issues table:
Issues w/applications, month, action taken, resolution target date, etc. (It is related to 1st subform by the survey ref#)

Thank You.
 
Hi!

Private cmdChangeSubform_Click()
If Me.subFrm.SourceObject = "subForm1" Then
Me.subFrm.SourceObject = "subForm2"
Else
Me.subFrm.SourceObject = "subForm1"
Endif
End Sub

Aivars
 
Aivars, I went into the Event tab under On Click and see the Open Form code, except I have no idea where to put the code you gave me? I'm sure it sounds stupid but do I replace the code that is there with your code or do I have to insert it somewhere? :0
Thank you by the way.
 
Hi again!

cmdChangeSubform - it's name of command button (switch of sub forms). Open Code window of event <your command button>
then copy:
'subFrm - Form's Subform name which link you want to change
If Me.subFrm.SourceObject = &quot;Your subForm1 Name&quot; Then
Me.subFrm.SourceObject = &quot;Your subForm2 Name&quot;
Else
Me.subFrm.SourceObject = &quot;Your subForm1 Name&quot;
End If

You may create only one subform on the form (may be without any link).

Aivars

 
I'm getting and error message:
Compile error:
Method or datamember not found

WHAT I DID-
I opened the code window of event for my cmdIssues.
I paste the copied code you sent me last.

Then I change &quot;Your subForm1 Name&quot; to &quot;frmKPIRating&quot; (In two places)
&quot;Your subForm2 Name&quot; to &quot;frmIssues&quot;

WHAT THE CODE LOOKS LIKE WHEN I'M DONE- (remember I'm not a programmer!)

Option Compare Database

Private Sub Issues_Click()
On Error GoTo Err_Issues_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;frmIssues&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Issues_Click:
Exit Sub

Err_Issues_Click:
MsgBox Err.Description
Resume Exit_Issues_Click

End Sub
Private Sub Issue_button_Click()
On Error GoTo Err_Issue_button_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;frmIssues&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Issue_button_Click:
Exit Sub

Err_Issue_button_Click:
MsgBox Err.Description
Resume Exit_Issue_button_Click

End Sub
Private Sub cmdIssues_Click()
'subFrm - Form's Subform name which link you want to change
If Me.subFrm.SourceObject = &quot;frmKPIRating&quot; Then
Me.subFrm.SourceObject = &quot;frmIssues&quot;
Else
Me.subFrm.SourceObject = &quot;frmKPIRating&quot;
End IfOn Error GoTo Err_cmdIssues_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = &quot;frmIssues&quot;
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdIssues_Click:
Exit Sub

Err_cmdIssues_Click:
MsgBox Err.Description
Resume Exit_cmdIssues_Click

End Sub

WHAT HAPPENS IF I TAKE ALL OF THE PREVIOUS CODE OUT AND PASTE YOURS IN-

Nothing


***JUST SHOOT ME NOW****
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top