Using OpenQuery But Not Displaying Results

DocB1973

Registered User.
Local time
Today, 06:38
Joined
May 12, 2010
Messages
16
I have several queries that are associated with the tabs on a tab control. They work just fine but I do not want them to open after they run. Does anyone know a workaround for this?

Thanks - Doc
 
Bob,

It is just a select query.

Thanks,
Doc
 
So I don't understand why you don't want them to open since they aren't really performing any updates to the source?

What is the purpose of the Select Query on the form?
 
I am using a unique query on each tab on a tab control and I want the results to display in the respective tab that the user clicks on. I hope that makes sense.
 
Are you using a subform on each tab? If you are all you need to do is set the Source Object of each subform to that query or create separate forms which you can use as the Source Object.

No need for OpenQuery.

Fyi: A form can be set to look like a query if you set it to Datasheet View.
 
No I am not using a subform. I just want to display the results of the query in each tab that corresponds to the matching controls.
 
It doesn't sound like your table isn't normalized.

So why are you calling OpenQuery? Set the form's Record Source property to the query and set the controls' Control Sources accordingly.
 
Let me take a look at that. The tab control event procedure looks like this:

Private Sub TabCtlCommodities_Change()
Dim stBatDocName As String
Dim stGenDocName As String

Select Case TabCtlCommodities
Case 0 'First Page
'Code for Page 1
stBatDocName = "qryZipToolTabControlBattery"
DoCmd.OpenQuery stBatDocName, acNormal, acEdit
Case 1 'Second page
'Code for Page 2
stGenDocName = "qryZipToolTabControlBattery"
DoCmd.OpenQuery stGenDocName, acNormal, acEdit
Case 2 'Third page
'Code for Page 3
End Select
End Sub

I have only referenced a query for the first and second tab until I can verify that the second tab is working.

Thanks,
Doc
 
I am using a unique query on each tab on a tab control and I want the results to display in the respective tab that the user clicks on. I hope that makes sense.

You don't run the queries to get that to happen. Unless you replace the form's recordset each time you click on a tab, you can't change the records like you think you can. You would need a subform for each tab if you don't want to change the form's recordsource.

And again, you don't run select queries to get data updated because whatever is bound to those queries actually runs them in the background. So if a form is assigned a query as its record source, whenever the form is opened, it has run the query and has the latest data. If you want it refreshed you would need to REQUERY the form like

Me.Requery (if the code is on the form to be requeried)

or

Forms!YourFormNameHere.Requery (if the code is not on the form to be requeried)
 
Bob,

Thanks for all your advice. I'll try the subforms and see if I have more luck with that.

Thanks,
Doc
 

Users who are viewing this thread

Back
Top Bottom