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!

Too few Parameters. Expected 2.

Status
Not open for further replies.

ClulessChris

IS-IT--Management
Jan 27, 2003
890
GB
The following is throwing the error "Too few Parameters. Expected 2."

I just can't see the error. Can sombody please help?

Code:
Private Sub AddDataToSheet(ByVal sTeamName As String, _
                    ByVal sSubject As String, ByVal dtReceived As Date, _
                    ByVal sStatus As String, ByVal dtAssigned As Date)
                    
    Dim sSql  As String
    
    sSql = "INSERT INTO tblDump ([Team Folder],Subject,Received,[Current Owner], Accepted) " & _
            "VALUES ('" & sTeamName & "','" & sSubject & "',[" & dtReceived & "],'" & sStatus & "',[" & dtAssigned & "])"
    
    CurrentDb.Execute sSql
    
End Sub

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
put a "debug.print sSql", and comment out the currentdb.execute.

Then post back what the sql string resolves. Likely you will see your problem. This is how you debug a sql string.
 


Hopefully not to phish! ;-)

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
This one is not bad, but I have seen people ask "what is wrong with my sql string" and it is about 40 lines long. I can see some problems such as a date without #s, but you never can tell until you print it out.
 
I experience the same type of problem but it does not make a difference if I use a sql in code or the actual select query.

When I change the query into a make table query and set the table as the recordset I can carry on with the rest of the work. What would make the difference? Nothing has change except going from a select query to a make table query?

Something I noticed, I have two queries that extract similar data, one extact it from a table while the other from a query. When I substitute the table query/Sql there is no problem but as soon as I replace it with the query query/sql the "expected two parameters" pops up. In case you ask why two different ones, well its part of the many see what work remnants.

Does the fact that several queries are involved bring forth this problem?

Sql from query

SELECT qryTSSCorrected.SampleDate, 2300 AS [Control Point], "RSP" AS Parameter, qryTSSCorrected.CorrTSS AS Results
FROM qryTSSCorrected
WHERE (((qryTSSCorrected.SampleDate)>=forms!frmMisaYear!txtDate1 And (qryTSSCorrected.SampleDate)<=forms!frmMisaYear!txtDate2) And ((qryTSSCorrected.SampleID)>3 And (qryTSSCorrected.SampleID)<11))
ORDER BY qryTSSCorrected.SampleDate, qryTSSCorrected.SampleID;

Sql from table

SELECT Misa3.Sampledate, Misa3.[Control Point], Misa3.Parameter, Misa3.Result
FROM Misa3
WHERE (((Misa3.[Control Point])<>400) AND ((Misa3.Parameter)="RSP"));


Thanks.

Hennie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top