Last Record in Combo Box

Ice Rhino

Registered User.
Local time
Today, 00:48
Joined
Jun 30, 2000
Messages
210
How do I set a combo box that is based around a select query to by default display the highest date value possible as the default when the form is opening.

I have a list of dates that are mmmm yy values and I just want it to popultae by default the combo box with the last month it detects in the list. The user can then override this if they want to.

Regards
 
How do I set a combo box that is based around a select query to by default display the highest date value possible as the default when the form is opening.

Sort your query by the date field in descending order, so that your highest data will be the first item in your combo box then use the following:

Me.MyCombo = Me.MyCombo.ItemData(0)
 
Thanks, is there a way of doing it from an ascending point of view?
 
yes, you can set it in ascending order from your query in the sort section choose ascending rather than descending.
 
Firstly let me say that I appreciate the suggestion which works exactly how you would imagine it to.

The only reason I asked about the ascending is that the list is used to be used in a earliest data first point of view. I understand the concept of what your suggestion puts forward and obviously as time goes on the list will grow and therefore to use itemdata(9) one month later will actually be number 10.

The other thing, the actual date that appears in the box is dd/mm/yyyy and not the format value of mmmm yy. Any idea how I can address this issue?

Regards
 
I guess another way of rewording the latter part of my previous question, is there a way of freshing the format command of a specific combo box so that the format will be displayed correctly?
 
to find the last item in the combo, i think you could use the recordcount property of the combo's rowsource query. not sure, though.

as for the format, maybe in the query section there'll be some help for how to adjust the format in SQL. I'm almost positive you'll have to format it in your rowsource query.
 
If you format the date in the underlying query, it will show the format in the combo box

ie DateMonth: Format([YourDateField],"mmmm yy")

to move to the last item in the combo use

Dim intX As Integer
intX = Me.YourCombo.ListCount
Me.cboName = Me.YourCombo.ItemData(intX - 1)
 
Thanks to all. I shall try all the suggestions posted and I am sure they will solve my issues.

Regards
 

Users who are viewing this thread

Back
Top Bottom