Combo Box to Default to Current Month

WineSnob

Not Bright but TENACIOUS
Local time
Today, 14:36
Joined
Aug 9, 2010
Messages
211
I have a combo box named cmbStartMonth that is based on a table with 2 fields. MonthNumber and MonthTxt. The combo box control is unbound. But the column bound property is 1 and the dropdown list shows the MonthTxt "January","February", etc. which is actually column 2.
I would like on form load to have the default value of the current month "July".
I have serached the forums and found a few things similar but could not get anything to work.
Thanks for your input.
 
In the form's load event set the combo value like this:

Me.cmbStartMonth = Month(Date())
 
Replacing MonthCombobox with the actual name of your Combobox:
Code:
Private Sub Form_Load()
 Me.MonthCombobox = Month(Date)
End Sub
Linq ;0)>
 
I get a type mismatch error. Is that an issue with the two columns in the row source?
 
Is the field Month Number really a text datatype? (it shoud not be if it is)
 
Month Number is a number long integer
 
If the bound column of the combo box is the month number there should be no type mismatch error. Do you have any procedure or object that is named DATE? That could be the issue. Perhaps this would then work instead:

Me.cmbStartMonth = Month(VBA.Date)
 
I created a new db with just the table and a form with just the cmbStartMonth and the code worked fine. I searched the Vb project and found no instance of date. I am at a loss.
 
I created a new db with just the table and a form with just the cmbStartMonth and the code worked fine. I searched the Vb project and found no instance of date. I am at a loss.

Try importing everything into a new blank database or try DECOMPILING first

http://www.granite.ab.ca/access/decompile.htm

and then compact and repair (do the decompile on a copy so you don't kill something accidentally).
 
I did the decompile and compact and repair and the issue is still there. However, I created a new form with just the combobox "in the same application" and it works. Therefore I conclude that it is something with the existing form. I will migrate the different controls one by one into the new form until it crashes. Thanks for your input.
 

Users who are viewing this thread

Back
Top Bottom