Ok. Fun one...
(working with Office 97)
I have an Excel file which automatically (via SQL) queries a time-tracking Access database and gets total time for all employees, for each cost code:
--- Begin Code ---
Dim dtBegin As Date, dtEnd As Date
Dim dbsDTDB As Database
Set dbsDTDB = OpenDatabase(strDTDBFileName)
' dtBegin and dtEnd are derived from an input
' box asking the user for the month
strSQL = "SELECT [Cost Code], [Description], " & _
"Sum([Time Spent]) AS [Total Minutes] " & _
"FROM [qryTimeEntryList-ForExportToTracie] " & _
"WHERE ([Date Worked] >= #" & Format(dtBegin, "Short Date" & _
"# AND [Date Worked] <= #" & Format(dtEnd, "Short Date" & _
"#) " & _
"GROUP BY [Cost Code], [Description] " & _
"ORDER BY [Cost Code]"
Set rstTotals = dbsDTDB.OpenRecordset(strSQL, dbOpenDynaset)
--- End Code ---
After querying the database, it creates a new Excel file, populates it with the query results, and automatically generates charts of the data.
All this works well.
I would now like to expand this functionality, to combine these results with the results of a totally different Access time-tracking system (different employees use different systems). The fields are pretty comparable (or I can make it so they will be).. I just can't figure out how to generate a union query between these two totally unlinked and unrelated databases. I would just link them.. except if possible, I would like to do everything from within the Excel file's code, without ever having to manually go into the Access files each month.
Thanks in advance for any ideas/code you may have!
(working with Office 97)
I have an Excel file which automatically (via SQL) queries a time-tracking Access database and gets total time for all employees, for each cost code:
--- Begin Code ---
Dim dtBegin As Date, dtEnd As Date
Dim dbsDTDB As Database
Set dbsDTDB = OpenDatabase(strDTDBFileName)
' dtBegin and dtEnd are derived from an input
' box asking the user for the month
strSQL = "SELECT [Cost Code], [Description], " & _
"Sum([Time Spent]) AS [Total Minutes] " & _
"FROM [qryTimeEntryList-ForExportToTracie] " & _
"WHERE ([Date Worked] >= #" & Format(dtBegin, "Short Date" & _
"# AND [Date Worked] <= #" & Format(dtEnd, "Short Date" & _
"#) " & _
"GROUP BY [Cost Code], [Description] " & _
"ORDER BY [Cost Code]"
Set rstTotals = dbsDTDB.OpenRecordset(strSQL, dbOpenDynaset)
--- End Code ---
After querying the database, it creates a new Excel file, populates it with the query results, and automatically generates charts of the data.
All this works well.
I would now like to expand this functionality, to combine these results with the results of a totally different Access time-tracking system (different employees use different systems). The fields are pretty comparable (or I can make it so they will be).. I just can't figure out how to generate a union query between these two totally unlinked and unrelated databases. I would just link them.. except if possible, I would like to do everything from within the Excel file's code, without ever having to manually go into the Access files each month.
Thanks in advance for any ideas/code you may have!