Hello Chris,
Check this link, which uses the dynamic recordset.
http://p2p.wrox.com/topic.asp?TOPIC_ID=44633
Okay, here you have a situation of getting the data from the same table
with all calculations on one or more fields (customed).
Here if it was SQL2000, I have guided you to use StoredProcedures to get
the data as you needed. In Access you cannot write SP only queries of
DDL and DML.
So all you have to do is, create a dynamic recordset, create all your
fields as needed, open the tblRepairs table with another recordset
with all proper SQL statement with where conditions, Make sure that
recordset holds the data which needs to be calculated on date diff,
then using DateDiff functions of VBA calculate the date between
two dates, and insert this value into the dyna recordset field.
Loop the main recordset of tblRepairs upto EOF and keep inserting
the data with all calculated values into this dyna recordset.
Finally you can bind this Recordset to the datagrid.
NOTE: above will require the ADO2.0 not DAO.
So, if you feel and want to stick on DAO itsself, then i have
another way to approach this situation.
1.
Just create another table with all fields you needed on output.
2.
open recordset, get the value from the table, use them for your
date calcultions. take all calculted data in respective variables.
3.
Keep inserting them into the table until you reach EOF.
4.
finally, you bind that table to the grid.
(Here you have to design a static table where design is not
changed every now and then, only the data in table will
deleted and new data is inserted every time you call this
function.
NOTE: these are the low level ideas to get the work done.
OR.
Open the recordset like Select A,B,C, datediff(e - f) as 'days' from table
name where ... alll conditions follow.
There are some other ways too, but our limitations is on T-SQL of MS-ACCESS.
So we have to program is such a way that my keeping them in mind.
well, i guess, its not a easy job to understand such process too soon.
needs some time to get the best solution to fit in.
anyway, just think about it and let me.
Hope this helps.
With Regards,
Raghavendra Mudugal