Trouble setting a value to a textbox with VBA in a form

BrotherBook

Registered User.
Local time
Today, 14:34
Joined
Jan 22, 2013
Messages
43
Hi-

I've been working on creating a new form to track prospect & clients. I have very little experience in Access programming (basically learned everything from google searches & this site).

I have a form to capture the creation of a prospect/client for our company. In this form there is a combobox (the name is "Type") to select "Prospect" or "Client. When the user saves the form I have a textbox hidden in which I want to capture the current date if the Type is set to client and that field has not previously been populated with a date. This is my current code which generates an error "Run-time error '2448': You can't assign a value to this object."

Code:
Private Sub Form_Close()
If (IsNull(Me.ProspectConversionDate.Value) = True And Me.Type.Value = "Client") Then
Me.ProspectConversionDate.Value = VBA.Date
Else
End If
End Sub

The point of this is to leave the ProspectConversionDate as null until the record is modified to be "Client", at which point upon close the form should populate the textbox with the current date. The field in the database ProspectConversionDate is bound to is a "Date/Time" format and the textbox format is "General Date".

Let me know if anything is not clear.

Thanks,
Mike
 
Problem solved. Seems Access didn't like this code in the OnClose event of the form. I moved it to the "AfterUpdate" event on the Type field and access handles it fine.
 

Users who are viewing this thread

Back
Top Bottom