find the correct cost to corresponding weight

B

BLTibbs

win xp and access 2003
I have a table postageTbl that has two fields, "maxweight" and
"PostageCost". I have a form with inventory records (attached to
InventoryTbl). The form has two fields, "weight" and "estimatedPostage".

I need to be able to scan (loop) through all of the maxweight amounts until
the weight in the "weight" field on the form is in the right category and
then import the corresponding cost into the "estimatedPostage" field on the
form.

How can this be done?
 
M

Marshall Barton

BLTibbs said:
win xp and access 2003
I have a table postageTbl that has two fields, "maxweight" and
"PostageCost". I have a form with inventory records (attached to
InventoryTbl). The form has two fields, "weight" and "estimatedPostage".

I need to be able to scan (loop) through all of the maxweight amounts until
the weight in the "weight" field on the form is in the right category and
then import the corresponding cost into the "estimatedPostage" field on the
form.


Let Access do the looping:

strSQL = "SELECT TOP 1 PostageCost " & _
"FROM postageTbl " & _
"WHERE maxweight >= " & Me.weight & _
" ORDER BY maxweight ASC"
Me.estimatedPostage = _
DbEngine(0)(0).OpenRecordset(strSQL).Fields(0)
 

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