displaying data from a query

W

Walter

I have created a db to keep mileage records for a
trucking company. In order to verify all mileages are
accounted for there are several things I need to do. On
the Trips form(parent), I enter a date and then select a
truck from a combo box for this trip. After the truck is
selected, I want to display the last odometer reading and
location recorded for this truck. I have created a query
(it takes 3) to find this information but I haven't
figured out how to get the results of this to show in the
text box controls I added to display this information.
I've tried setting the control source to the field in the
query and or setting the default value to this field but
all I get is #Name.

I also need to validate the odometer entry to >= the last
od for this truck but have been unable to accomplish this
either.

If possible, I would like to validate the date >= the
last trip date. At present, the date is entered first,
however it could be entered after the truck is selected
if necessary.

Another issue is, since I have to report miles traveled
in each state, I need to set the default entry for the
state = to the state entry for the last record for this
truck.

These mileage and state controls are on a subform based
on the trip details table.

I know I am asking a lot but if someone can be specific
as how to accomplish these things with some explanation
in common terms to help me understand it I would be
greatly appreciative.
TIA,
Walter
 
M

Michel Walsh

Hi,


To get the information associated with the "latest" information (time wise),
for one truck, you can use:


SELECT TOP 1 *
FROM myTable
WHERE truckID=[param]
ORDER BY dateTime DESC


to get the same information, but for all the trucks, take a look at
http://www.mvps.org/access/queries/qry0020.htm


Hoping it may help,
Vanderghast, Access MVP
 

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

Similar Threads

DMax/DLookup help 3
sub or function not defined 4
MsgBox problem 22
entry validation 2
How is 869343 less than 869330????? 6
Validation incorrect 5
Mileage Query 1
adding criteria to limit results 4

Top