Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another form entry validation question.

Status
Not open for further replies.

LD1010

Technical User
Dec 6, 2001
78
US
I'm working on a vehicle maintenance DB. On the frmServiceEntry one of the required entry field is ServiceMileage. I'm trying to validate that the mileage enter here is >= to the last mileage update for the vehicle. Mileage update information comes from two different sources, from tblService to which the afore mentioned form frmServiceEntry is bound, and from the table tblCurrentMileage. (Once a month the current mileage of every vehicle is entered in this table.) I then have a query qryMileageMax that gives me the highest mileage for each vehicle from two other queries, qryServiceMileageMax and qryCurrentMileageMax. I also have a subform sfrmMileageMax on my entry form that displays the last recorded mileage for the vehicle, the link Child/Master fields being VehicleID. It's a great visual feed back, but unfortunately that doesn't keep the user from entering a mileage lower than the last recorded mileage.

I'm not sure how to go about this and hoping the more experienced can guide me. Your help is always much appreciated.
 
If you already have a field showing the last recorded mileage on your form, just add an on exit event to the ServiceMileage field.

It should have something like:

Dim Response
if me.ServiceMileage < me.sfrmMileageMax then
Beep
Response = MsgBox("Mileage must be greater than last mileage recorded?", vbCritical)
docmd.gotocontrol "controlname"

End If


 
How are ya LD1010 . . .

I've learned to just go ahead and give the thread originator what there after. However, In your case, I'm compelled to present the following:

[blue]Logically[/blue] your only interested in changes in milage. This means that new mileage entered has to be greater [blue]>[/blue] than prevous mileage ... not [blue]>=[/blue]. If your logging date of change thru a date field, time span should be easy to see.

Since your only logging [blue]changes in mileage[/blue] thru frmServiceEntry that are [blue]>[/blue] than previous, updating [blue] tblCurrentMileage[/blue] at the same time would keep you current ... period, despite monthly updates!

[blue]Your Thoughts on this Schema? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks for response AceMan. Your right, I am only interested in changes in mileage. Although the instances would be rare it is possible that a vehicle being serviced would, before it goes on the road that day, have it’s monthly mileage read and updated, then be pulled into the shop for repair. In this case the correct mileage on the odometer would be the same, not higher, than the last update.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top