Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Unanswered: Combo box data source

    Hi,
    I want to create a combo box that will give me a list of my queries. I've seen somewhere on the web how this can be done but unfortunately I can't find it

    Anyone know how this can be done? (I'll also do the same thing with my reports)

    Regards
    John

  2. #2
    Join Date
    Jun 2004
    Posts
    96
    not sure if this is the easy way for you, but it's the only way I know:

    use the below function and assign the return string to the combobox.rowsource

    *****
    Function GetQueryList() As String
    Dim Qry As QueryDef
    Dim QryList As String

    QryList = ""
    For Each Qry In CurrentDb.QueryDefs
    QryList = QryList & Qry.Name & ";"
    Next Qry
    GetQueryList = QryList
    End Function

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    Put the next string as the RowSource of your ComboBox

    PHP Code:
      SELECT MSysObjects.NameMSysObjects.FlagsMSysObjects.Type
         FROM MSysObjects
            WHERE 
    (((MSysObjects.Flags)<>-2147483648 And         
               (
    MSysObjects.Flags)<>And (MSysObjects.Flags)<>-2147483645) AND 
               ((
    MSysObjects.TypeIn (5)))
             
    ORDER BY MSysObjects.Name
    yourCombo.RowSource="Select ......"

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by Cyherus
    not sure if this is the easy way for you, but it's the only way I know:

    use the below function and assign the return string to the combobox.rowsource

    *****
    Function GetQueryList() As String
    Dim Qry As QueryDef
    Dim QryList As String

    QryList = ""
    For Each Qry In CurrentDb.QueryDefs
    QryList = QryList & Qry.Name & ";"
    Next Qry
    GetQueryList = QryList
    End Function

    That is also fine, but you should define the RowSourceType as "Value List"

  5. #5
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Thanks for that Hammbakka, it works perfectly.

    As I don't really inderstand the code, well not at all actually, I take it that one part of the SQL statement is referring only to queries, but which part. The reason I ask is that I want to do the same with reports and certain forms.

    Regards
    John

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    For reports use the following:
    PHP Code:
      SELECT MSysObjects.NameMSysObjects.FlagsMSysObjects.Type
        FROM MSysObjects
         WHERE 
    (((MSysObjects.Type)=-32764))
       
    ORDER BY MSysObjects.Name

  7. #7
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Hi Hammbakka,
    Thanks for that, much appreciated

    Regards
    John

  8. #8
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You are welcome, here is that of Forms

    PHP Code:
    SELECT MSysObjects.NameMSysObjects.FlagsMSysObjects.Type
      FROM MSysObjects
        WHERE 
    (((MSysObjects.Type)=-32768))
           
    ORDER BY MSysObjects.Name

  9. #9
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Excellent, twas my next question!

Posting Permissions

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