Results 1 to 4 of 4

Thread: ComboBox with Access

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    alb, nm 87112
    Posts
    56

    Post

    First, and foremost, Happy Holidays to all.

    Now, my question.

    I have a database with approximately 26 tables. Each of these tables have a "Date" field. I need the combobox in my program to list the dates, beginning with the oldest, and finishing with the latest.

    Any ideas?

    Thanks!

  2. #2
    Junior Member
    Join Date
    Aug 1999
    Location
    Cary, NC, USA
    Posts
    17

    Post

    Create a new table (#27) and keep all dates in this table with a key in each of the 26 tables pointing to it's date field in the new table. Then use this code:

    Sub Add_Dates_To_Combo()

    Dim rsDates as Recordset, strSQL as String

    strSQL = " SELECT * FROM <table 27's name> ORDER BY [<Date Field Name>] DESC"

    Set rsDates = dbData.OpenRecordset(strSQL, dbOpenSnapShot)

    If rsDates.RecordCount < 1 then Exit Sub 'Error handling for 0 dates in table

    Do While Not rsDates.EOF
    Combo1.AddItem rsDates.Fields("<Date Field Name>")
    rsDates.MoveNext
    Loop

    End Sub

    Do not use the <> around the field names and you will need to define dbdata and open the database... if you need help with that part let me know and I will help you there too.

  3. #3
    Lively Member
    Join Date
    May 1999
    Location
    Vancouver, BC, Canada
    Posts
    84

    Post

    Create a union query based on the date fields in all the tables.
    Set the row source of the combobox to query...base this query on the union query and set unique values = yes

  4. #4
    Lively Member
    Join Date
    May 1999
    Location
    Vancouver, BC, Canada
    Posts
    84

    Post

    Oh yeah, I forgot...set sort order to descending!

Posting Permissions

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



Click Here to Expand Forum to Full Width