run more than 1 query and display on form

qwertyjjj

Registered User.
Local time
Today, 10:18
Joined
Aug 8, 2006
Messages
262
Is it possible to run more than 1 query and display results on the same form?
I have 1 form with a Record source of Query 1.

The control boxes can therefore just reference the query fields.
So, Control box 1 has =[selectedfieldfromQuery1] as its control source.

I need to have a second control box displaying the value of a different query from a different table.
So, at the moment Control box 2 has =[Query2]![selectedfieldfromQuery2] as its control source but Access doesn't recognise that.

ANy ideas on how to progress?
 
The record source of the form will be either a query or table and all bound controls on the form will need to be part of that record source. You cannot refer to a different record source in the way you have tried to do.

The only way (that I know of) to do this is to write a function that returns the result of a query (SQL statement in the function). Then create an unbound control on the form and set the control source of that control to be the function [=functionname()]. Remember of course that the function can only return a single value.

Maybe some of the real Access gurus on this forum (and there are plenty of them) can come up with a better answer.

Hope this helps a little bit.
 
Alternatively, you could create another query that selects both two queries and use that as a record source.

I can't guarantee you that if it'll be updatable, though.
 
How can a query be designed to select 2 queries?

Basically, I have a SQL query selecting figures from 1 table. It als has grouping ad SUM functions.
Therefore, I cannot combine the second table into that query as it affects the SUM results. Essentially, there is no relationship between table 1 and table 2 anyway.

I guess I could use an expression to do the calculating but it seems much easier to do it in a query.

Is there another way, perhaps retrieveing a record set in some VBA code maybe ?
 
How can an Access form be a true form if you can't populate control / textboxes with different SQL queries ?
 

Users who are viewing this thread

Back
Top Bottom