Combo Box issue

newbie87

Registered User.
Local time
Today, 15:14
Joined
Sep 9, 2011
Messages
43
Hi All,

I have a combo box on my form and I use a dlookup to populate this with the highest Age from my table.

is there any way to populate this combo box with the highest age and counting backwards to the lowest age?

For example:
highest age = 25
lowest age = 17

so the combo box would be:
Code:
Age:   25
       24
       23
       22
       21
       20
       19
       18
       17

Many thanks
 
How do you find the Lowest value? Instead of Using DLookUp why not try DMin and DMax?? Works exactly like DLookUp but returns the minimum value in the Column of the Table referenced and DMax returns the Maximum value.. So then you can use something like this..
Code:
Private Sub displayCombo()
Dim minAge As Integer
Dim maxAge As Integer
Dim rowStr As String
minAge=DMin("[COLOR=Blue]columNameOfAge[/COLOR]","[COLOR=Blue]tableWhereItResides[/COLOR]")
maxAge=DMax("[COLOR=Blue]columNameOfAge[/COLOR]","[COLOR=Blue]tableWhereItResides[/COLOR]")
rowStr = maxAge
For i = maxAge To minAge Step -1
    rowStr = rowStr & ";" & i
Next
Me.[COLOR=Blue]comboBoxName[/COLOR].RowSource = rowStr
End Sub
Change the Blue bits to match your code.
 
Many thanks for your quick response.

Your code works like a treat, thank you :D
 

Users who are viewing this thread

Back
Top Bottom