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 strongm 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 - Too Few Parameters. Expected 2

Status
Not open for further replies.

Sillygirl

Programmer
May 3, 2002
80
US
Basically, I'm trying to pull information from a table and compare it to the form values. Can someone help me with this error?

Set DBs = CurrentDb()

Criteria = "SELECT * from tblEX2MFRAME WHERE Forms![frmP6ABViewActive]![subfrmP6abViewActive].Form![GMIN] = [tblEx2MFRAME]![GMIN] AND Forms![frmP6abViewActive].Form![txtFormatAppDate] = [tblEx2Mframe]![APPL_DATE]"


Set Myset = DBs.OpenRecordset(Criteria)

its blowing up on the Set Myset command.

Thanks in advance. [dazed]
-Sillygirl

 
You need to use the values from the forms:

[tt]Criteria = "SELECT * from tblEX2MFRAME WHERE [tblEx2MFRAME]![GMIN] = " & Forms![frmP6ABViewActive]![subfrmP6abViewActive].Form![GMIN] & " AND [tblEx2Mframe]![APPL_DATE]=#" & Format(Forms![frmP6abViewActive].Form![txtFormatAppDate],"yyyy/mm/dd") & "#"[/tt]

If GMIN is text, you will need single quotes.
 
Thanks so - much for your help. However, how would you put the single quotes in if they comment out the line?

Thanks in advance.
 
Like so:

[tt]Criteria = "SELECT * from tblEX2MFRAME WHERE [tblEx2MFRAME]![GMIN] = [red]'[/red]" & Forms![frmP6ABViewActive]![subfrmP6abViewActive].Form![GMIN] & "[red]'[/red] AND [tblEx2Mframe]![APPL_DATE]=#" & Format(Forms![frmP6abViewActive].Form![txtFormatAppDate],"yyyy/mm/dd") & "#"[/tt]

Single quotes enclosed in quotes do not comment out a line.

 
I could use a hand with this problem also.

I've got the following query which looks fine when it outputs to the msgBox, but comes back with a 3061 error.

Also, does Access have a Query Analyzer something like SQL Server?

Thanks,

devRyan
 
Helps if I posted the query :/

Code:
strSQL = "SELECT lnkCourseEmployee.EmpCourseID, lnkCourseEmployee.CourseID, lnkCourseEmployee.EmpID, " & _
        "lnkCourseEmployee.DateComplete,lnkCourseEmployee.HoursTrained,lnkCourseEmployeeCompleted, " & _
        "tblCourses.CourseName FROM lnkCourseEmployee, tblCourses WHERE lnkCourseEmployee.EmpID = '" & EmpID & "' " & _
        "AND lnkCourseEmployee.CourseID = tblCourses.CourseID"
    MsgBox strSQL
    Set rsC = db.OpenRecordset(strSQL)
 
devRyan
It is best to start your own thread. That being said, check the value and field type for EmpID. Numeric fields do not need single quotes.

If this is not the answer, or even if it is, do not reply in ths thread.


 
Assuming your empid and and courseID are numeric, it should look like this instead.

strSQL = "SELECT lnkCourseEmployee.EmpCourseID, lnkCourseEmployee.CourseID, lnkCourseEmployee.EmpID, " & _
"lnkCourseEmployee.DateComplete,lnkCourseEmployee.HoursTrained,lnkCourseEmployeeCompleted, " & _
"tblCourses.CourseName FROM lnkCourseEmployee, tblCourses WHERE lnkCourseEmployee.EmpID =" & EmpID & " AND lnkCourseEmployee.CourseID =" & tblCourses.CourseID

You will have to fix the wrapping problem on the last line, but that might do it.

if they are not numeric, let me know and I'll show you the difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top