Perfimace a query after entry data in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How to performance several queries in a predetermined order at a form?
I have some queries that calculate values that I use I other queries to
calculate other values. I want to after I place all the data of a new record
the form performance all the queries in the right order. Pretty much all that
I can do how is add several buttons to run each form.
 
You can put code in the After Update event of the form where you enter the
data to perform whatever tasks you need to do in the order you want them.
 
How to performance several queries in a predetermined order at a form?
I have some queries that calculate values that I use I other queries to
calculate other values. I want to after I place all the data of a new record
the form performance all the queries in the right order. Pretty much all that
I can do how is add several buttons to run each form.

This seems like a very odd way to do things.

It is almost NEVER necessary to run even one action query in order to
do calculations. Running several is even less common.

To directly answer the questions, you can create a Macro or (better) a
VBA subroutine to execute action queries (using the RunQuery action in
a macro, or the querydef Execute method in VBA).

However, I very strongly suspect there are better ways to accomplish
what you want to do! Could you explain what these queries are doing?

John W. Vinson[MVP]
 
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.
thanks for the atencion
"John Vinson" escreveu:
 
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]
 
It didn't work after all, I tried to make a module with the stament you gave
me and then I make a macro that run is. I guess what you told me wolud work
for sure but I just don't how to set it up

"John Vinson" escreveu:
 
Back
Top