Hi,
I am using Access 2000 and have a problem with Recordsets and a QueryDef. No matter what I try whenever I run the code I keep on getting "Too few parameters. Expected 1"
After a long time reading past treads I have discoved that the problem is normally becouse I am tring to open a rescordset to a query that refers to a form which mine does and therfore my query is no longer a select query it is now a QueryDef.
In my code I now have a string that stores my stl statment (SqlStr) and my open recordset now referes to that but I still get the same message.
Heres my Code:
Dim DB As DAO.Database
Dim myRecord As DAO.Recordset
Set DB = CurrentDb()
Dim SqlStr As String
SqlStr = "SELECT Main.Name, Main.Date, Main.Action FROM Main WHERE (((Main.Name)=[forms]![Switchboard]![cobName]) AND ((Main.Date)=Date()));"
Set myRecord = DB.OpenRecordset(SqlStr)
With myRecord
If .RecordCount Then .MoveFirst
Do Until myRecord.EOF
If ![Action] = "Resolved" Then
Counter(1) = Counter(1) + 1
ElseIf ![Action] = "Reassigned" Then
Counter(2) = Counter(2) + 1
ElseIf ![Action] = "Rejected" Then
Counter(3) = Counter(3) + 1
ElseIf ![Action] = "Handled" Then
Counter(4) = Counter(4) + 1
End If
Loop
End With
Form_DataSheet.labResolved.Caption = Counter(1)
Form_DataSheet.labReassigned.Caption = Counter(2)
Form_DataSheet.labRejected.Caption = Counter(3)
Form_DataSheet.labHandled.Caption = Counter(4)
And if you need it here is the query I tried to use is bassically just brings up the records for a certain persion(combo box on a form) and for the current date.
SELECT Main.Name, Main.Date, Main.[Reference Number], Main.Account, Main.Action, Main.[R\R Reason], Main.Time, Main.[Approx Time], Main.Group, Main.CallOver20
FROM Main
WHERE (((Main.Name)=[forms]![Switchboard]![cobName]) AND ((Main.Date)=Format(Date(),"Short Date"))
ORDER BY Main.Time;
Please plesae please can you help it's driving me crazy.
Many Thanks
Phil
I am using Access 2000 and have a problem with Recordsets and a QueryDef. No matter what I try whenever I run the code I keep on getting "Too few parameters. Expected 1"
After a long time reading past treads I have discoved that the problem is normally becouse I am tring to open a rescordset to a query that refers to a form which mine does and therfore my query is no longer a select query it is now a QueryDef.
In my code I now have a string that stores my stl statment (SqlStr) and my open recordset now referes to that but I still get the same message.
Heres my Code:
Dim DB As DAO.Database
Dim myRecord As DAO.Recordset
Set DB = CurrentDb()
Dim SqlStr As String
SqlStr = "SELECT Main.Name, Main.Date, Main.Action FROM Main WHERE (((Main.Name)=[forms]![Switchboard]![cobName]) AND ((Main.Date)=Date()));"
Set myRecord = DB.OpenRecordset(SqlStr)
With myRecord
If .RecordCount Then .MoveFirst
Do Until myRecord.EOF
If ![Action] = "Resolved" Then
Counter(1) = Counter(1) + 1
ElseIf ![Action] = "Reassigned" Then
Counter(2) = Counter(2) + 1
ElseIf ![Action] = "Rejected" Then
Counter(3) = Counter(3) + 1
ElseIf ![Action] = "Handled" Then
Counter(4) = Counter(4) + 1
End If
Loop
End With
Form_DataSheet.labResolved.Caption = Counter(1)
Form_DataSheet.labReassigned.Caption = Counter(2)
Form_DataSheet.labRejected.Caption = Counter(3)
Form_DataSheet.labHandled.Caption = Counter(4)
And if you need it here is the query I tried to use is bassically just brings up the records for a certain persion(combo box on a form) and for the current date.
SELECT Main.Name, Main.Date, Main.[Reference Number], Main.Account, Main.Action, Main.[R\R Reason], Main.Time, Main.[Approx Time], Main.Group, Main.CallOver20
FROM Main
WHERE (((Main.Name)=[forms]![Switchboard]![cobName]) AND ((Main.Date)=Format(Date(),"Short Date"))
ORDER BY Main.Time;
Please plesae please can you help it's driving me crazy.
Many Thanks
Phil