Get value for field from another query (1 Viewer)

peng21

New member
Local time
, 23:05
Joined
Feb 19, 2014
Messages
9
Hello,

It might be a simple question but I don't know how to solve this:

First:
I've created a simple query which gives me the result for a given user input "p".

Code:
SELECT TOP 1 val1
FROM tblPerson
WHERE( (val2)<=[p] )
ORDER BY val2 DESC;

Result looks like:
...|..val1...
...| 12345


Now I've a second query.
I would like to get the value for discount from the query above by "putting in p"

Code:
Field.......level......... discount
Table.......adbCases...... qryDiscountGet
Total.......expression.....Group By
Criteria...................[p]=[level]

Can anyone help me please how to solve this?

Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 07:05
Joined
Nov 30, 2011
Messages
8,494
Hello peng21, Welcome to AWF :)

Show a bit more sample data, it is not clear from your description what you want to do.
 

peng21

New member
Local time
, 23:05
Joined
Feb 19, 2014
Messages
9
Ok, here we go :)

Sample data of tblDiscount
tblDiscount.png


Sample data of tblAdbCases
tblAdbCases.png


Running (qryDiscountGet)
Code:
SELECT TOP 1 discount
FROM tblDiscount
WHERE( (level)<=[p] )
ORDER BY levelDESC;
Should return for [p]=7 "discount = 8.25 USD"


Now I would like to create a query:
"Show me all entries and calculate the discount based on the level"

Access Design View for my query
Code:
Field.......level......... discount
Table.......adbCases...... qryDiscountGet
Total.......expression.....Group By

I hope it's now more clear :)

Thanks
 

Users who are viewing this thread

Top Bottom