The following line of code:
qdf.Parameters(0) = sYr
is producing a runtime error 3265 “Item not found in this collection”
I know I can use a form for the qdf.Parameters(0) line like this:
qdf.Parameters(0) = [Forms]![frm52Weeks]![cboYr]
But I don’t want to use a form in this particular instance, I want the parameter to come from an input box. The user enters a four digit number for the year e.g. 2008. The data type for the year field in the table is number not date.
This is a portion of the code I’m using.
Can anyone help with the proper syntax?
Thanks for looking at this.
qdf.Parameters(0) = sYr
is producing a runtime error 3265 “Item not found in this collection”
I know I can use a form for the qdf.Parameters(0) line like this:
qdf.Parameters(0) = [Forms]![frm52Weeks]![cboYr]
But I don’t want to use a form in this particular instance, I want the parameter to come from an input box. The user enters a four digit number for the year e.g. 2008. The data type for the year field in the table is number not date.
This is a portion of the code I’m using.
Code:
Dim sYr As String
sYr = InputBox("Enter Year Please")
If sYr = "" Then
MsgBox "You did not enter a year", , "Aborting..."
Exit Sub
End If
Set db = CurrentDb
Set qdf = db.QueryDefs("qryWeeklySumsQK")
qdf.Parameters(0) = sYr
Set rs = qdf.OpenRecordset
Do While Not rs.EOF
If rs!SumOfNet > 1 Then
tmpWin = tmpWin + 1
tmpLoss = 0
End If
If rs!SumOfNet < 1 Then
tmpLoss = tmpLoss + 1
tmpWin = 0
End If
If tmpLoss > ConsqLWk Then ConsqLWk = tmpLoss
If tmpWin > ConsqWWk Then ConsqWWk = tmpWin
rs.MoveNext
Loop
Me.txtConsecWWk.Value = ConsqWWk
Me.txtConsecLWk.Value = ConsqLWk
rs.Close
qdf.Close
Can anyone help with the proper syntax?
Thanks for looking at this.