passing parameters from one query to another

G

Guest

I have two queries, where each accept parameters. I'm using the DLookup to
call the one query from within the other, however I don't know how I go about
sending the parameters from the outer query to the inner. Below are my
queries.

Query1. (name = sp_GetTableInvoiceNo)
SELECT Invoice_Number
FROM Invoice_OnHold
WHERE OnHoldID = [@TableNo]
AND Cashier_ID = [@CashierID]
AND Store_ID = [@Store_ID];

Query2. (name = sp_GetInvoiceItems)
SELECT ItemNum, Quantity
FROM Invoice_Itemized
WHERE Invoice_Number=DLookup("[Invoice_Number]","sp_GetTableInvoiceNo")
And CashierID=[@CashierID]

As you can see I need to pass 3 parameters from the outer query to the
inner. How can this been do.

Thanks
 
M

Michel Walsh

Hi,


Try using a function rather than a stored procedure (I assume you use MS SQL
Server).


Hoping it may help,
Vanderghast, Access MVP
 
G

Guest

I'm using access

Michel Walsh said:
Hi,


Try using a function rather than a stored procedure (I assume you use MS SQL
Server).


Hoping it may help,
Vanderghast, Access MVP


Coss said:
I have two queries, where each accept parameters. I'm using the DLookup to
call the one query from within the other, however I don't know how I go
about
sending the parameters from the outer query to the inner. Below are my
queries.

Query1. (name = sp_GetTableInvoiceNo)
SELECT Invoice_Number
FROM Invoice_OnHold
WHERE OnHoldID = [@TableNo]
AND Cashier_ID = [@CashierID]
AND Store_ID = [@Store_ID];

Query2. (name = sp_GetInvoiceItems)
SELECT ItemNum, Quantity
FROM Invoice_Itemized
WHERE Invoice_Number=DLookup("[Invoice_Number]","sp_GetTableInvoiceNo")
And CashierID=[@CashierID]

As you can see I need to pass 3 parameters from the outer query to the
inner. How can this been do.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top