Access Error 3061?

Hi,

Weird problem here ...

I'm calling a function from a module.
The function contains this: 'db.OpenRecordset("qSendMailIndiv", dbOpenDynaset, dbSeeChanges)'

Now if that query contains this criteria: [Forms]![fPropDetail]![IDDemande] then the function will produce an error 3016 ('not enough parameters') but when I remove that criteria then it works alright ... but I need the criteria!? So what can I do?

Thanks a lot!

Jerome
XeronimoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
first is the form "fPropDetail" open when you run the query?


also, try changing the criteria

[Forms]![fPropDetail]![IDDemande]

to

Eval("[Forms]![fPropDetail]![IDDemande]")

post back the result
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
You get the error because when opening a query in VBA, your in control.   Normally Access resolves parameters for you, but when you do it, you need to take care of that.

See the following:

http://www.experts-exchange.com/Database/MS_Access/Q_25011143.html

For how to do that.

Jim.
0
Rey Obrero (Capricorn1)Commented:
<ot>
@jim
did you register to the WebCamp (aspx) ?
rey
</ot>
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

XeronimoAuthor Commented:
Rey:

Yes, the form is open when the function is called. And there are additional criteria in the query too (a date and a string) but they do not cause an error. It's only the criteria which references a field on a form that causes it.

The eval() does not work in the query (it's an 'Access query', not a 'code query') ...
0
XeronimoAuthor Commented:
Jim: I'm referencing a query that I've created using the GUI in my VBA code ... so I'm not sure how your link fits in there?

When I open the query manually it works just fine; it gets the data from the form without a problem.
But when I call the query from VBA then it throws this error ... I'm still a bit lost.
0
Rey Obrero (Capricorn1)Commented:
post the function you are using..
0
XeronimoAuthor Commented:
Public Function sendEmailInfoSup(Zort As String)

Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Object
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim MyBodyText As String
Dim LoginCode As String

Set MyOutlook = CreateObject("outlook.application.14")

Set db = CurrentDb()

If (Zort = "all") Then
Set MailList = db.OpenRecordset("qSendMail", dbOpenDynaset, dbSeeChanges)
Else: Set MailList = db.OpenRecordset("qSendMailIndiv", dbOpenDynaset, dbSeeChanges)
End If

...

Open in new window


"qSendMail" does not have the criteria referencing to the form, so that one works alright.
"qSendMailIndiv" does have that criteria and it produces the error (except, of course, when I remove that criteria)

The SQL of the second query looks like this:

SELECT dbo_tInscripActiv.IDInscripAct, dbo_tInscripActiv.travMail, dbo_tInscripActiv.titre, dbo_tInscripActiv.dateSaisie, dbo_tInscripActiv.etat, dbo_tInscripActiv.nom, dbo_tInscripActiv.prenom
FROM dbo_tInscripActiv WHERE (((dbo_tInscripActiv.IDInscripAct)=[Forms]![fPropDetail]![IDDemande]) AND ((dbo_tInscripActiv.dateSaisie)>#7/1/2014#) AND ((dbo_tInscripActiv.etat)="ok"))
ORDER BY dbo_tInscripActiv.IDInscripAct;

Open in new window

0
Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
<<Jim: I'm referencing a query that I've created using the GUI in my VBA code ... so I'm not sure how your link fits in there?>>

  Even though you created the query in the GUI, your still executing it in code with the statement:

db.OpenRecordset("qSendMailIndiv", dbOpenDynaset, dbSeeChanges)

 When a query has a parameter, like a form reference, you must supply the value before you try to execute it.  That means either:

a. Opening it first and supplying all the parameter values.

b. If control references, wrapping them with Eval() in the query itself.

 When you open a query "manually", your using Access, which automatically tries to resolve any parameters.   If it cannot get a value for a parameter, you get prompted for the value.

 But since your opening this in code, you need to do everything.

Jim.
0
XeronimoAuthor Commented:
Jim: Ah, ok! And it works with Eval() in the query now ... don't know why it didn't the first time I tried ... Thanks! :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.