Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009

    Unanswered: Combo box values based on a function?

    Hi. I have a form where there is an unbound combo for the user to select a week (i..e week 1 to 52). Instead of filling all these numbers in manually, is there a way to use a function to create the values?

    eg in my case it would be Datepart("ww", Date()) + 1 to get the next value. and then just select some limits.

    Is this possible? I know in this case it's easy to just write out all the numbers but I need it for something more complicated.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    You can adapt this simple piece of code:
    Option Compare Database
    Option Explicit
    Private Sub Form_Open(Cancel As Integer)
        Me.Combo0.RowSource = MyList(1, 10)
    End Sub
    Public Function MyList(Lower As Integer, Upper As Integer) As String
        Dim i As Integer
        MyList = Lower
        For i = Lower + 1 To Upper
            MyList = MyList & "; " & CStr(i)
        Next i
    End Function
    Have a nice day!

  3. #3
    Join Date
    Jun 2009
    works perfectly, thanks~!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts