G
Guest
Hi, i have a large form that im trying to manipulate to auto fill some fields
when other fields get typed in. For instance right now the first tab of the
form is the Date tab. If someone inserts the date I would like the Year to be
automatically added on an AfterUpdate Event... here is my code.
Private Sub itemDate_of_Incident_AfterUpdate()
Dim MyDate As Date
MyDate = Forms![frmIncident]![itemDate of Incident].Value
MyVar = CDate(MyDate)
Forms![frmIncident]![itemYear].Value = Year(MyVar)
End Sub
I've tried about everything. It's weird because I can go into the Debug
window and type each of these in seperately and it gives the correct Year in
the year text box.
Any help will be greatly appreciated. Thanks. And im getting an error
message on the line
Forms![frmIncident]![itemYear].Value = Year(MyVar)
I when I put the cursor over Year(MyVar)... it says Type Mismatch
Can't figure it out, lmk. Thanks
when other fields get typed in. For instance right now the first tab of the
form is the Date tab. If someone inserts the date I would like the Year to be
automatically added on an AfterUpdate Event... here is my code.
Private Sub itemDate_of_Incident_AfterUpdate()
Dim MyDate As Date
MyDate = Forms![frmIncident]![itemDate of Incident].Value
MyVar = CDate(MyDate)
Forms![frmIncident]![itemYear].Value = Year(MyVar)
End Sub
I've tried about everything. It's weird because I can go into the Debug
window and type each of these in seperately and it gives the correct Year in
the year text box.
Any help will be greatly appreciated. Thanks. And im getting an error
message on the line
Forms![frmIncident]![itemYear].Value = Year(MyVar)
I when I put the cursor over Year(MyVar)... it says Type Mismatch
Can't figure it out, lmk. Thanks