Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error 3061

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
This is probably something very obvious, but I'm experiencing brain block on it so far.

I'm trying to send emails to multiple users, and the message sent depends on a T/F column in one of the tables. Setting up the database prior to sending the note is what's not allowing me to compile. I receive this error:

Run-time error '3061.'
Too few parameters. Expected 2.


I tried hitting help, but nothing comes up. The debug pgm points to the "Set rstEmail..." line in the following code:

Code:
'Send email notifications to CardHolders
    Set dbs = CurrentDb
    Set qryEmail = dbs.QueryDefs("qryEmailInfo")
    qryEmail.Parameters("pHeaderID") = CLng(txtHeaderID)
    Set rstEmail = qryEmail.OpenRecordset
 
With rstEmail
    If .RecordCount > 0 Then
        Do While Not .EOF
        ' Check for missing data
        '   Email address
        If Nz(.Fields("StaffEmail")) = "" Then
            MsgBox "Card holder, " & .Fields("StaffFName") & " " & .Fields("StaffLName") & _
                    ", does not have an email address" & vbCrLf & _
                    "Check listing against sent items folder", _
                vbInformation + vbOKOnly, _
                "Missing Email"
        Else
            strTo = .Fields("StaffEmail")
.
.
.


VB is looking for a second parameter, but I don't understand what it is. Can anyone help?

Thanks in advance,
Kerry
 
Hmmmm.....

1. Make sure qryEmailInfo has it's paramaters set. The first line of your SQL statement should look something like:

PARAMETERS [pHeaderID] Text;
SELECT * FROM (blah blah)

2. Can you run the qryEmailInfo from the QBE enviroment ??/ What does it ptompt you for when you run it.

3. Is qryEmailInfo a crosstab or a groupby query ?? Cross tabs have to have column names when you run them from code.

Tyrone Lumley
augerinn@gte.net
 
Thank you for your response, Tyrone.

1. I thought I had set the parameters with the line that says:
qryEmail.Paramters("pHeaderID")=CLng(txtHeaderID)

Then later I do a Select Case so that the correct email is sent--it's based on the status of a T/F column.


2. When the query is run right from QBE is prompts me for the pHeaderID.

3. The qryEmailInfo is a regular query, not a crosstab query.

Don't know if that helps. I could post or email the entire cmdSend code if that would help.

Thanks again for your help,
Kerry
 
We're getting close. It's the query itself that needs parameters set, not your code.

Go to the query in the QBE window. Right click somewhere in the grey area, and highlight the parameters property. Enter phHEader under parameter, and whatever datatype it is suppossed to be in the data type field.

Viwe your SQL to insure the first line includesd the Parameter statement.PARAMETERS [pHeaderID] Text;

Note: may not say text based on the data type you choose.
Tyrone Lumley
augerinn@gte.net
 
OK, I'll give those changes a try, but I'm a bit confused as to what exactly I'm doing. Why do I have to set the query parameter to PHeaderID and include it in the SQL?
What does it do?

Kerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top