Date Field Check against Saved Date?

Heatshiver

Registered User.
Local time
Tomorrow, 03:27
Joined
Dec 23, 2011
Messages
263
I have a combobox that checks for saved dates and allows someone to choose from the drop-down if they want to go back and change values in the fields from that date. I have a date field with a date picker to choose a date that has yet to be saved.

My issue is that if a person uses the date picker and chooses an existing date (instead of the combobox), I get an error for the combobox code once they try to save.

I was thinking that a simple VBA code in the Lost Focus event of the date picker could fix this. It would say something to the effect of:

If Date Chosen = Existing Date Then
MsgBox("Use combobox for existing dates")​
datepickerField.SetFocus​
datepickerField.Clear​
End If

Essentially, the user would be unable to choose an existing date from the date picker, and would have to use the combobox instead.

I don't know how to write out the first part "Date Chosen = Existing Date". All I could think of was "DTPicker0.Value =" or "Me.DTPicker0.Value = ", but wasn't sure how to check it against existing dates.

Thanks!
 
why do you need both the combo box and the date picker ?
if you want them both to update the same field you should make the combo as unbound, and use it's afterUpdate event to update another field that will hold the date.
The date picker will update this same field.
 
The date picker is so that they can choose a new date from anytime. The combobox is so that they can see what dates have been used and change the values in those dates if necessary.

Will your suggestion still only have the combobox list all the dates used? Or will it have all dates?
 
The combo take it's data from a query, irrelevant if the combo field is bound or not. In this query you can put what ever you wish, in your case only dates already used.

You can also keep the combo bound but change it's .LimitToList properties to No. this will enable the user either select a date from the combo or write any other date.
This way you can also use the DatePicker to put any date you wish in the combo field.
 
It's a great suggestion, but doesn't seem to work quite right.

I locked the other date picker field and took away the calendar (it's pretty much just for display now). I changed the "Limit to List" to No on the combobox.

I can write in any date I want for the combobox, but it doesn't allow me to save that date when I click the Save Record button.

I tried my New Record button and then the date picker field shows the current date, but the combobox doesn't change. I then put in some values and click the Save button, but it doesn't save.

The only way I can save new data is to unlock the date picker field and choose a new date from there.
 
If you upload a simplified version of your db I can try to have a look
 

Users who are viewing this thread

Back
Top Bottom