Retrieving values in the last column of a query or selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Two of my tables are Tracking (primary key TrackID) and QuoteItems (primary
key QuoteID). A Tracking Object can have any number of QuoteItems. Say if the
current form Tracking Object TrackID=2, has the QuoteItems QuoteID = 3,4,5, I
want to be able to count through the quotes in VBA code so I can retrieve
values from all the QuoteItems for a particular Tracking Object. How do I get
the value of the of the first and last value of the QuoteID of a particular
Tracking Object so I can set up a loop.
Thanks in advance
 
Hum, first I think you mean the last row...not column?

Further, that QuoteID is not likely to be sequential in nature, so, grabbing
the min value, and then grabbing the max value, and then using the two
values to traverse the data will not work.

You can certainly tell the database engine to go get a list of quote items
and then process that list. However, you would not use the max, or min
values in any way to process that list (you simply process the list until
done, or until "end of list".

Further, there are data engine commands to grab the max value, or the min
value of a list, and you might be able to do that.

Further, it is not clear what you need, or want to do with this list. If you
need to display the list, then just use a sub-form, and no code will be
needed.

If you need the max value, then again, you don't have to loop, but simply
use some sql, or the dmax command to do that for you.

You might be better asking how to do what you want in place of thinking that
you need a loop here (perhaps you do!!).

And, it also helps where/when you want to do this. For example, in a report
that would list the tracking info, and ONLY the LAST quote item, you could
use sql to do this for you, and again the report would not need any code, or
a loop...
 
Back
Top