I work in the construction business and I’m taking spreadsheet and turning in
a access data base. I keep loosing info so I decide to put all together in a
data base, I build 12 table linked together by an id number and made more 12
queries do to do all de calculation I need. I use the type of query that adds
line to a table so I can keep in my data base all the results and also make
easier to access to make calculus that is base in other previews calculated
values. And every thing is linked to an id number, so I have to do run the
queries in the right order.
All the calculus are working fine but I need something to make all then run
in the right time and after that open an report or an other form.
You may want to consider doing the calculations in Excel (Excel is
very good at that <g>) and importing the resulting spreadsheet page
into Access; but if what you're doing is working, simply run the
queries from VBA code, perhaps in the Click event of a command button.
If there are that meny queries, I'd suggest setting up a small table
named CalcQueries with one text field QueryName containing the name of
each query, and a numeric field Seq containing a number specifying the
order in which the queries should be run. You could then run code
like:
Private Sub cmdRunQueries_Click()
Dim db As DAO.Database
Dim qd As DAO.Querydef
Dim rs As DAO.Recordset
Dim strSQL As String
On Error GoTo Proc_Error
Set db = CurrentDb
strSQL = "SELECT QueryName FROM CalcQueries ORDER BY Seq;"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveFirst
Do Until rs.EOF
Set qd = db.Querydefs(rs!QueryName) ' get the query name to execute
qd.Execute, dbFailOnError
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Proc_Exit: Exit Sub
Proc_Error:
MsgBox "Error " & Err.Number & " in cmdRunQueries_Click:" _
& vbCrLf & Err.Description
Resume Proc_Exit
End Sub
John W. Vinson[MVP]