Here is My code for starters:
At the line, NumOrdTotal = rs1!varLongMont h + Val(NumOrd) , I get an error saying: Item not found in Collection.
I believe I am getting this error because where the field belongs at rs1!"fieldName" I have a variable. I need to be able to use this variable to identify the field depending on certain criteria. How can I use this variable to do that?
Code:
Select Case varMonth
Case Is = 1
varLongMonth = "January"
Case Is = 2
varLongMonth = "Feburary"
Case Is = 3
varLongMonth = "March"
Case Is = 4
varLongMonth = "April"
Case Is = 5
varLongMonth = "May"
Case Is = 6
varLongMonth = "June"
Case Is = 7
varLongMonth = "July"
Case Is = 8
varLongMonth = "August"
Case Is = 9
varLongMonth = "September"
Case Is = 10
varLongMonth = "October"
Case Is = 11
varLongMonth = "November"
Case Else
varLongMonth = "December"
End Select
txttest = varLongMonth
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Query_2")
rs1.MoveFirst
Do Until rs1.EOF
If rs1![ID] = Val(ID) Then
NumOrdTotal = rs1!varLongMonth + Val(NumOrd)
rs1.Edit
rs1!varLongMonth = NumOrdTotal
rs1.Update
End If
rs1.MoveNext
Loop
rs1.Close
Set rs1 = Nothing
Set db = Nothing
I believe I am getting this error because where the field belongs at rs1!"fieldName" I have a variable. I need to be able to use this variable to identify the field depending on certain criteria. How can I use this variable to do that?
Comment