|
-
Dec 8th, 1999, 03:15 AM
#1
Thread Starter
Member
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!
-
Dec 8th, 1999, 06:55 AM
#2
Junior Member
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.
-
Dec 8th, 1999, 07:15 AM
#3
Lively Member
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
-
Dec 8th, 1999, 07:17 AM
#4
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|