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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp /access 2003 question

Status
Not open for further replies.

neronikita

Technical User
Feb 20, 2002
159
US
I will apologize for the confusing explanation ahead of time... I'm not sure exactly how to word exactly what it is I'm looking for, so I'll just do my best.

I'm in the process of creating a database in Access to use to track maintenance for a trucking company. One of the tables in the db is TruckINfo and it contains the unit numbers. Another table is TruckService and it contains the service records. The user has requested a page that lists the unit numbers, allows him to select what is there that day, enter the current mileage, and have it return the difference in mileage from the last time it was seviced to determine if it needs to be serviced. I'm not sure how to get the same field to list multiple times on one asp page, then have them select the units applicable and then have the mileage entered (which is also the same field multiple times), and then how to have this field compare to the most recent service milease for the matching unit and all that. The final product can display either on the same page or in a summary report, flagging those meeting certain criteria (over 15,000, 20,000, or 30,000 miles for example). Can anyone point me in the right direction or even tell me what to search for? I'm fairly new to ASP, but from what I've done it seemed like the best tool to use to do this.

Thanks in advance!
 
Are you working with ASP or ASP.NET?

In ASP listing the same field multiple times for multiple rows is done with a loop. You retrieve rows for all of the trucks you wish to show using a SELECT query. This gives a recordset. Then you loop through the rows in the recordset. Each time through the loop you write the HTML for displaying the data for one row. Then move to the next row and repeat.

When you build <INPUT> fields inside the loop you need to give each one a different name. For example, mileage_1, mileage_2, etc.

For the calculation of mileage difference there are a couple of approaches. One would use Javascript, the other would submit the form and calculate the difference followed by re-display showing the difference.

With the Javascript approach you would build hidden fields to hold the previous mileage. Define a function that calculates the difference between the entered mileage and the previous mileage. Assign this function to the onchange event for each mileage field. The result can be displayed in a dynamic <DIV> or in another form field.

With the Submit approach, the entered value is submitted to your script, you obtain the previous value, calculate the difference then build the page again this time showing the difference. The previous value could be obtained from the form data as in the Javascript approach or it could be retrieved in a new query.

So there is actually a lot to this customer requirement. Take it step by step. Get the dsiplay part working then move on to one of the calculation approaches. Dont think this is easy cause it is not, but it is definitely doable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top