J
jb33
newbie.
this is code fired by an onchange event in my form. I've
gotten through setting the reference for DAO and removing
it for ADO, but now this.
When the code goes to fire, I get a Compile Error: Object
required message. 'thisdate =' is highlighted - the
first set statement - in the debugger. If I comment out
that line, the numdays line is highlighted. I've tried
setting to constants with the same error.
Any idea why? Something wrong with my declaration or set
statement?
tia, jb
Private Sub start_date_Change()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim numdays As Byte
Dim counter As Byte
Dim thisdate As Date
Set thisdate = Me![start_date]
Set db = CurrentDb()
Set rs = db.OpenRecordset("workdays", dbOpenDynaset)
Set numdays = Me![days_required]
Set counter = 1
Do While counter <= numdays
With rs
.AddNew
!activity_id = Forms![Phase Form]!activity_id
!Date = thisdate
.Update
End With
counter = counter + 1
thisdate = DateAdd("d", 1, thisdate)
Loop
Proc_Exit: Exit Sub
Proc_Error:
MsgBox "Error " & Err.Number & " in <procedurename>:" &
vbCrLf & _
Err.Description
Resume Proc_Exit
End Sub
this is code fired by an onchange event in my form. I've
gotten through setting the reference for DAO and removing
it for ADO, but now this.
When the code goes to fire, I get a Compile Error: Object
required message. 'thisdate =' is highlighted - the
first set statement - in the debugger. If I comment out
that line, the numdays line is highlighted. I've tried
setting to constants with the same error.
Any idea why? Something wrong with my declaration or set
statement?
tia, jb
Private Sub start_date_Change()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim numdays As Byte
Dim counter As Byte
Dim thisdate As Date
Set thisdate = Me![start_date]
Set db = CurrentDb()
Set rs = db.OpenRecordset("workdays", dbOpenDynaset)
Set numdays = Me![days_required]
Set counter = 1
Do While counter <= numdays
With rs
.AddNew
!activity_id = Forms![Phase Form]!activity_id
!Date = thisdate
.Update
End With
counter = counter + 1
thisdate = DateAdd("d", 1, thisdate)
Loop
Proc_Exit: Exit Sub
Proc_Error:
MsgBox "Error " & Err.Number & " in <procedurename>:" &
vbCrLf & _
Err.Description
Resume Proc_Exit
End Sub