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

Using Option Groups 2

Status
Not open for further replies.

integritycare

Technical User
Mar 12, 2011
151
AU
Hi all,
Really would appreciate some help on this issue.
I have a mainform on which I have a subform. On the mainform I would like to put an option group which can slect the differing queries for the subform.

The code I am using for the oprion group is;

Code:
Private Sub Frame1_AfterUpdate()
Select Case Frame1.Value

Case 1
Me.RecordSource = "Admin" 
 Case 2
Me.RecordSource = "Training" 
Case 3
Me.RecordSource = "SystemManagement" 
Case 4
Me.RecordSource = "Service Delivery" 
Case 5
Me.RecordSource = "Safety" 
Case 6
Me.RecordSource = "Templates" 
Case 7
Me.RecordSource = "Induction" 

End Select
End Sub

I realise that i could uput these on the continous form but wanted to put them in a vertical display.

So how do I relate this code so that when selected on the mainform it will select the query for the subform.

Many thanks

Integrity
 
Replace this:
Me.RecordSource
with something like this:
Me![name of subform's control].Form.RecordSource

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
If the fields of each of these queries are not the same then you will have issues. If the fields are the same then I'm not sure why multiple similar queries. I would expect a single query with different filters/criteria.



Duane
Hook'D on Access
MS Access MVP
 
How are ya integritycare . . .

In parallel with [blue]PHV[/blue] ... if the names given (Admin, Training, ect) are actual query names then you'd have:
Code:
[blue]Private Sub Frame1_AfterUpdate()
   Dim RS As Property
   
   Set RS = [[purple][B][I]subFormName[/I][/B][/purple]].Form.Properties("RecordSource")
   
   Select Case Frame1
      Case 1
         RS = "Admin"
      Case 2
         RS = "Training"
      Case 3
         RS = "SystemManagement"
      Case 4
         RS = "Service Delivery"
      Case 5
         RS = "Safety"
      Case 6
         RS = "Templates"
      Case 7
         RS = "Induction"
   End Select
   
   Set RS = Nothing

End Sub[/blue]
You can also replace the query names with SQL:
Code:
[blue]   RS = "SELECT ... FROM ..."[/blue]
Also bear in mind: when you write to the recordsource of a form it automatically requeries!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks Guys,
I need to give all a star for this reply. I have noted dhookom's reply. All the fields are the same.. so will look at the rest of his comments.
PHV and TheAceman1, thnaks for your replies. I will now uses your thoughts in this situation.

Many thanks

Integrity
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top