View Full Version : Can't assign value to this object ERROR


lmangano
12-19-2000, 03:53 PM
I'm not sure why I'm having such a hard time with this because I've done it before with a combo box, but when I use the following code with a text box, I get the "Can't assign value to this object." If the user doesn't enter a pend date, I want it to assign the current date + 7 days to the PEND_DT field in my Table. Maybe I'm using the wrong event?

Private Sub Form_Close()
Dim strHoldDate

'Returns current system date plus 7 days
If IsNull(txtPendDate) Then
strHoldDate = DateAdd("d", 7, Date)
Me![PEND_DT] = strHoldDate
End If

End Sub

Thanks!
Liz

Jack Cowley
12-19-2000, 04:40 PM
This code in the FORMS Before Update event should work for you. It would also work in the On Exit event of the txtPendingDate field, but someone could mouse past it and not trigger the code.

If IsNull(Me![txtPendDate]) Then
Me![PEND_DT] = Date + 7
End If

lmangano
12-20-2000, 08:39 AM
It's working now. Thanks a lot!
I put the code in the After_Update event of another control on the form that is required. The Before_Update event of the FORM wasn't triggering. It's probably just the way that I have the form setup.
Thanks for your help.
-Liz