Combo Box with Dates

Joshann

Registered User.
Local time
Today, 06:10
Joined
Mar 22, 2002
Messages
142
I have searched for an answer to this seemingly simple question, but can't find one. I have a combo box bound to a table containing dates. The combo box's Format property is set to Short Date. I have the following code in the Not In List event of the combo box:
Code:
Dim rst As New ADODB.Recordset
Dim cn As ADODB.Connection
    
Set cn = CurrentProject.Connection
    
rst.Open "Dates", cn, adOpenKeyset, adLockOptimistic
rst.AddNew
rst!PhotoDate = NewData
rst.Update
rst.Close
Me.cmbDateTaken.Value = FormatDateTime(NewData, vbShortDate)
Response = acDataErrAdded

This works fine if the user does not enter any leading zeros in the date. For example, the user enters 5/4/2004 rather than 05/04/2004. However, if the user does enter leading zeros, the error message saying that the text you entered isn't an item in the list comes up even though the new date does appear in the list. I figure this is because Access isn't recognizing that 5/4/2004 and 05/04/2004 are the same. That's why I tried the line: Me.cmbDateTaken.Value = FormatDateTime(NewData, vbShortDate). That does convert the date entered by the user to include no leading zeros, but it still doesn't work. Does anyone have any suggestions?
 

Users who are viewing this thread

Back
Top Bottom