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 Mike Lewis 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 1

Status
Not open for further replies.

ruru9292

IS-IT--Management
Jan 31, 2005
29
0
0
US
Hello,

I am trying to enable some fields on my form if some criteria in my query is valid. However I am getting error 3061 too few parameters: expected 2.

for simple explanation, I put two fields abc & xyz on my form, and onloading form I am calling sub to enabled these fields if they match my query. Below is my code.

Thanks in Advance

Private Sub Form_Load()
Dim cn As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("MyQry")...Here is the error

rs.MoveFirst
Do Until rs.EOF
Select Case rs!QryField
Case abc
Me.abc.Enabled = True
Case xyz
Me.xyz.Enabled = True
End Select
Loop
End Sub

Note: I have a field in MyQry called QryField & it retrieves abc & xyz & other data which match the fields' names on my form. Moreover; MyQry is not bound to this form.

Please Advice.
 
The SQL code of MyQry contains references to 2 unknown fields. Feel free to post it.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hello,

Thanks PH. it helps in a way that I have to make MyQry generate new table called MyQryTbl as shown in my query below. is there a way to run my Select query instead of Make table query directly without generating new table? below is my Code. ... Thanks again.

Private Sub Form_Load()
Dim cn As DAO.Database
Dim rs As DAO.Recordset
DoCmd.OpenQuery "MyQry", acViewNormal, acEdit
Set db = CurrentDb()

...myqry reads the code below
SELECT Subject.SubId, Subject.TeacherID, Subject.Grade, SubList.DepartmentName, SubList.TabName INTO MyQryTbl
FROM Subject INNER JOIN SubList ON Subject.Subject = SubList.DepartmentName
WHERE (((Subject.TeacherID)=[Forms]![usersFrm]![InstructorID]) AND ((Subject.Grade)=[Forms]![StudentsFrm]![Grade]));


Set rs = db.OpenRecordset("MyqryTbl")
If Not rs.EOF Then
rs.MoveFirst
End If
Do Until rs.EOF
Select Case Trim(rs!tabname)
Case "IHtTab"
Me.IHtTab.Enabled = True
Case "LanEngTab"
Me.LanEngTab.Enabled = True
.
.
.
End Select
rs.MoveNext
Loop
rs.Close
db.Close
End Sub
 
You may try this:
Dim strSQL As String
strSQL = "SELECT Subject.SubId, Subject.TeacherID, Subject.Grade, SubList.DepartmentName, SubList.TabName" _
& " FROM Subject INNER JOIN SubList ON Subject.Subject = SubList.DepartmentName" _
& " WHERE Subject.TeacherID='" & [Forms]![usersFrm]![InstructorID] & "'" _
& " AND Subject.Grade='" & [Forms]![StudentsFrm]![Grade] &"'"
Set rs = db.OpenRecordset(strSQL)

Both usersFrm and StudentsFrm must be opened main forms.
If either TeacherID or Grade is defined as numeric then get rid of the corresponding single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top