Create new record, dependant on previous

G

Guest

Hi
Is it possible to create a new record, that is dependant upon a previous
record.

I am using my database to record bus mileages and I need to make sure that
when i enter the mileages for each bus, that the start mileage is not less
than the last finish mileage I entered for that bus.

At the moment I am just entering the records individually, and having to
check the start against the finish manually.

Unfortunately the records I am inputting from fall into this problem
reguarly, so I there is a way I can get a message box or something to tell me
that my start mileage is invalid, that would be great.

Many thanks for your help.

Steve A
 
S

solex

Assuming your table is like this:

BusMileage
BusMileageID
BusID
StartMileage
EndMileage

In the Form_BeforeInsert and the Form_BeforeUpdate events you can do a quick
check

SELECT Max(EndMileage) FROM BusMileage WHERE BusID = YourFormControl.BusID

Using the resultant recordset you can check the EndMileage against the one
the value the user entered for the StartMileage and set the value of the
cancel argument in the eventhandlers appropriately.

Dan
 
G

Guest

Hi,
Thanks for that, I think I see what you are meaning, but I'm not quite sure
how to implement it. Any advice would be greatly appreciated. Thanks in
advance.

My mileage table is as follows...

JobNumber (ID)
Date
FleetNo (Bus, linked to bus table)
StartMiles
FinishMiles
StartKm
FinishKm
Fuel L
Fuel C
Bio
ChangesMiles
ChangesDead
MReason
DReason
Service (Linked to Service Table)
Comments
 

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


Top