MS Access Database calculations
I've created a datatbase for a list of vehicles and need to reduce the value of all vehicles with registrations before J by 10%.
Can any 1 through any suggestions pleeze?????
Software
I've created a datatbase for a list of vehicles and need to reduce the value of all vehicles with registrations before J by 10%.
Can any 1 through any suggestions pleeze?????
by dklippert
Copy the table first, for safety sake.
Now Create a Query and then on the Menu choose Query> Update Query
Fill in the criteria and then use a value in the Update to: cell such as [Value]*.9
Look up Update_Query in the help file.
by neilmay2
by shmaltz
I beleive that by before j you mean a-i or a-j.
Here is what you can do (first backup everything):
This is all done using VBA in access.
1. Create a function that will host this sub, and name it what ever you want.
2. Open the Recordset that hosts the data (using whatever you like, DAO or ADO).
3. Loop thur the recordset (using the EOF property) using the movenext method of the recordset object (remember to first use the movefirst, otherwise you might get a no current record error).
4. Ateach record inspect the field that has the registration number, assigning it to a temp ver, then use the mid$ function to capture just the first letter (i.e. strreg = trim$(mid$(rs("registration"),1,1))
5. Next test if it is J or less using the following test:
if asc(strreg)>64 and asc(strreg) <75 then
rs("value")=rs("value")*.9
elseif asc(strreg)>96 and asc(strreg)<107 then
rs("value")=rs("value")*.9
endif
in the above example I assumed that J is to be included. If it is not to be included then change 75 for 74 and 107 for 106
Run the code, you should now be good.
I used the following assumptions:
A. You know how to use VBA
B. The value of the vehicle is stored in a field called value and is of the data type number
C. The registration number is stored in the field called registration and is of type text.
If you nedd any help email me.
by neilmay2
by neilmay2
This discussion is closed to new replies.
Sort by Trending