Click to See Complete Forum and Search --> : ComboBox with Access
Dan0331
Dec 8th, 1999, 02:15 AM
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!
Magik
Dec 8th, 1999, 05:55 AM
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.
jkurpias
Dec 8th, 1999, 06:15 AM
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
jkurpias
Dec 8th, 1999, 06:17 AM
Oh yeah, I forgot...set sort order to descending!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.