By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 2,482 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

How To Set A Variable Like [acc] From Another Query?

P: 2
Hi, this is literally driving me mad, to me it seems the simplest thing in the world to do but I have found absolutely no way of doing it.

Simply put I have a query which i'll call Query1 where it asks for input in the form:

[ACC]

I also have another query that uses Query1 for its information. How ON EARTH do I pass a variable to Query1 for [ACC]. It pops up with a textbox everytime but I don't want that, I want it to be filled in automatically with a value I give it. Something simple like [ACC]="RB123456" but nooooooo that does nothing.

I have absolutely no idea how to continue. I've literally been looking how to do this for the past 2 hours. Some advice please.

TIA
Jan 5 '07 #1
Share this Question
Share on Google+
6 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Hi, this is literally driving me mad, to me it seems the simplest thing in the world to do but I have found absolutely no way of doing it.

Simply put I have a query which i'll call Query1 where it asks for input in the form:

[ACC]

I also have another query that uses Query1 for its information. How ON EARTH do I pass a variable to Query1 for [ACC]. It pops up with a textbox everytime but I don't want that, I want it to be filled in automatically with a value I give it. Something simple like [ACC]="RB123456" but nooooooo that does nothing.

I have absolutely no idea how to continue. I've literally been looking how to do this for the past 2 hours. Some advice please.

TIA
You have to keep the form open that populates the [ACC] value in query1 while running query2.

Mary
Jan 6 '07 #2

P: 2
Hi thanks for your reply, its much appreciated.

The problem is I don't know how to populate the [ACC] variable. I can only put data into this variable when it pops up as an inputbox. I can't pass information to it from another query. Simply put I would like to be able to set the [ACC] variable in query2 to a value say 'RB123456', which would then be sent to query1, without the inputbox popping up.

The way the database is set up, I have a query which takes information from a very large database of billions of records. I then run a second query on this query. Supposedly I could merge the two queries into one but it would over complicate things and give me a giant bit of SQL code.

How do I skip the inputbox stage and have the query fill in this box automatically. Or do I have to use a global string or another method?

At the moment I'm not using a form but I will be eventually. How do I solve this using just a query?

Thanks in Advance, I appreciate you spending your own time in offering your advice.
Jan 7 '07 #3

100+
P: 1,646
Hi thanks for your reply, its much appreciated.

The problem is I don't know how to populate the [ACC] variable. I can only put data into this variable when it pops up as an inputbox. I can't pass information to it from another query. Simply put I would like to be able to set the [ACC] variable in query2 to a value say 'RB123456', which would then be sent to query1, without the inputbox popping up.

The way the database is set up, I have a query which takes information from a very large database of billions of records. I then run a second query on this query. Supposedly I could merge the two queries into one but it would over complicate things and give me a giant bit of SQL code.

How do I skip the inputbox stage and have the query fill in this box automatically. Or do I have to use a global string or another method?

At the moment I'm not using a form but I will be eventually. How do I solve this using just a query?

Thanks in Advance, I appreciate you spending your own time in offering your advice.
Hi. You need to post code for this. In particular we need to know both queries without abbreviating them even if you think that part of it is not relevant.

When you are looking at query design mode go to view sql and paste the text here
Jan 7 '07 #4

nico5038
Expert 2.5K+
P: 3,072
Did you try to use a subquery like:

SELECT A.*
FROM tblX A INNER JOIN (select B.* from tblY B where B.ID=[ACC]) ON tblA.A = B.A;

Just replace the present queryname with "(", the SQL text from query and ")"

Nic;o)
Jan 7 '07 #5

pks00
Expert 100+
P: 280
If u have a form which takes input for ACC, how have u defined your SQL?

Did u do [ACC] or did u reference the form?

i.e.

forms!nameofmyform!ACC
Jan 7 '07 #6

NeoPa
Expert Mod 15k+
P: 31,186
An intriguing question - and sorry to give you more replies to respond to but,
How are the two queries (#1 & #2) related?
Do you want to call (refer to) #2 from within #1?
Or maybe you want to call them one after the other from some code?
Do you have a form from which they will both be called?
These are important bits of information which will effect the answer as there are many possible answers depending on what the question actually is.
I always recomment answering ALL requests for information, but I will await you response to mine :)
Jan 7 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.