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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subform calling a specific query

Status
Not open for further replies.

brianjay

Programmer
Sep 14, 2000
42
US
I'm sure that this is simple; but I'm lost

I have a form with 26 Cmd Buttons (Cmd_A - Cmd_Z). I also have 25 querys (Qry_A - Qry_Z); each calling up specific info. All of the buttons open the same form; but with different properities on it (color, text, logo, etc.). The form has 1 subform (Sub_Info) on it and I want to select a button (Cmd_T) and have the query (Qry_T) show the data in the subform.

What do I need to do to get that result

Brian
 
Do you wish to set the Source Object of the subform to Query T in the Load event of the called form?
 
I believe that, that is what I want to do. I want it so that the sequence is as follows:

1) click the "T" button on the "switchboard"
2) "switchboard" closes, "Main Form" opens" (this part is done).
3) "Main form" opens with the title "T" and the appropriate logo showing (this part is done).
3) On this form; the subform appears with the data from "QrY_T" showing.

What coding do I use and where do I stick it?
 
I think OpenArgs may be the best bet. If the query is called qry_T (or qry_A, ... qry_Z) your life may be easier.

Open form
Code:
Sub Open_Click()
'It may be possible to say Screen.ActiveControl.Name
'Have you looked at the Customer Phone List in the
'Northwind sample database?

DoCmd.OpenForm "frmWithSubform", , , , , , "T"

End Sub

On 'frmWithSubform'
Code:
Private Sub Form_Load()
If Me.OpenArgs <> "" Then
    Me.qry_subform.Form.RecordSource = "qry_" & Me.OpenArgs
End If
End Sub
 
brianjay . . .

You never answered [blue]Remou[/blue] and started the same thread again? . . .

Calvin.gif
See Ya! . . . . . .
 
i placed the question in 3 areas hoping to get an answer. I don't always get answers when placing in 1 forum. I'm a beginer and Remou's answer although good is a bit confusing for me. Your answer has shed some light on his though. I'm still lost, but i am getting there.
 
brianjay . . .

Apparently you've never read faq181-2886. particularly the 4th entry!

In any case if something is confusing why not say so or ask for a better explanation!

[blue]Its bad etiquette to leave a thread hanging![/blue]

If you ask I'm sure [blue]Remou[/blue] can explain it so you do understand! . . .

Calvin.gif
See Ya! . . . . . .
 
I apologize for the confusion and the bad etiquette that I've shown. The 2 of you have been VERY helpfull; but I don't seem to understand the directions that I get from programmers. i know that I have a lot to learn so PLEASE bear with me.

Let me try to start over with this with the real info used.

I have a form (Frm_Main) that has 25 buttons on it. The buttons are baseball teams. All of the buttons bring up form #2 (Frm_Current_Teams). The this form populates with the proper logos and team names (no problem here). Inside this form is a sub form called "sub_team_players".

I would like to display the different querys in this subform when the appropriate button is clicked.

ex.: Select "Baltimore Orioles" and Qry_Baltimore_orioles appears in "sub_team_players" subform with the logo and the players appear on the form. Go back to the main menu and select "Phila. Phillies" and Qry_Philladelphia_Phillies players appears in the subform.

I hope this helps. The Northwind phone list may work, but that has the buttons on the same form as the info and I have my buttons 2 forms earlier.

Am I making this more complicated that I need too.

brianjay
 
Presumably the logos and so on are coming froma table yes no? Add another field to the table called say, TeamQuery, with the name of the query for each team. You can then use this to populate your subform. Use the Form Load event of Frm_Current_Teams:

Code:
Private Sub Form_Load()
    Me.sub_team_players.Form.RecordSource = TeamQuery
End Sub

Does that seem more workable for you?
 
Remou and TheAceMan1

THANK YOU. With some reading and setting up the proper variables; I was able to get the querys to appear in the proper forms

Again, I'm sorry for the miscommunication - but THANK YOU again

brianjay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top