well I don't know any more what to do, I tried to take out all de parameters
a see if would work, but still showing the same message, than I tried too
replace with the code you send me and the same massage still coming up. I'm
quite sure I need a new way of doing that. The thing is I have lots of
calculations and got so big that I had to you several queries. That's
happened because my database is all about keeping the results of those
calculation, but to get all right I need to do them in the right order. I
have 12 queries that make those calculations and save them in a new line on a
predetermined table. I have the same thing in a spreadsheet but the company
was getting big and things was getting lost once every time I needed the
number for my business a new spreadsheet was made, so I did all in access.
after a long journey tiring to make work I did it .all the calculus are store
right in the right place, but it is kind bad having to run all these queries
in the right order, so what I really need is something that do that for me in
just a click, but that is getting quite hard. I hope with this description
you can help me a little more
thanks
"Douglas J Steele" escreveu:
Actually, I didn't mention anything about "the value of rs". I asked about
the value of rs!QueryName: in other words, are you getting the name of a
legitimate query when you refer to rs!QueryName.
However, AFAIK, you can't use parameter queries this way: you need to
provide the value of the parameter before you .Execute.
Do Until rs.EOF
Set qd = db.QueryDefs(rs!QueryName) ' get the query name to execute
qd.Parameters("n° da obra") = Value
qd.Execute, dbFailOnError
rs.MoveNext
Loop
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
The names of the queries are correct, I double check. They have parameter.
Avery time I run any of the queries I have to put in the Id number, that
is
call [n° da obra]
I don't know what you neam by the value of rs. PS I don't know what is RS
"Douglas J Steele" escreveu:
Your translation of the error message was good: AccessError(450) returns
"Wrong number of arguments or invalid property assignment" in English
What's the value of rs!QueryName when the error occurs? Does a query by
that
name actually exist? Is the query expecting parameters?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I think I finally getting somewhere, I set it up as you told me and
right
after I click the button the vba page open up. It tried to run the
code
but
could not it says there is an error just like the one I told you
before.
The
error number is the 450. The parts underline are the same that vba
highlight
when I execute the procedure. The translation of the error is
something
like
that-n° of arguments incorrect or property attribution invalidly. At
lest
the
vba is tring too run when is suppose to.
---Private Sub cmdRunQueries_Click()--- (this part)
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 (the word execute is also hightlight)
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
Thanks in advance
"Douglas J Steele" escreveu:
Private Sub cmdRunQueries_Click() implies that this code needs to
be in
the
code associated with a form, that the form in question has to have a
command
button on it named cmdRunQueries, and that you've set the Click
property
for
the cmdRunQueries command button to [Event Procedure].
If that isn't the situation you have right now, try renaming the
procedure
to simply Sub RunQueries(), and then you can invoke the routine
using
Call
RunQueries()