Hello,
Using VB, I am trying to export MSAccess select query table to excel. This Select query table has 2 parameter fields, month and year, so while exporting this table, it asks for user input month and year. In the VB program, this 2 parameter is already known, how can I pass this 2 fields to the access query, so that it exports the table without asking for user input? I will appreciate your help very much. Thankyou.
Sub ExportToExcel()
Dim acApp As Access.Application
Dim exApp As Excel.Application
On Error GoTo errExportToExcel
Screen.MousePointer = vbHourglass
Set acApp = CreateObject("Access.Application"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
acApp.Application.OpenCurrentDatabase "Placements.mdb"
acApp.DoCmd.TransferSpreadsheet acExport, 8, "Placements", "Placements.xls", True, ""
Set exApp = CreateObject("Excel.Application"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
exApp.Workbooks.Open "Placements.xls"
exApp.Application.Visible = True
exApp.Application.ActiveWorkbook.Activate
Set acApp = Nothing
Set exApp = Nothing
Screen.MousePointer = vbDefault
Exit Sub
End Sub
Santosh
Using VB, I am trying to export MSAccess select query table to excel. This Select query table has 2 parameter fields, month and year, so while exporting this table, it asks for user input month and year. In the VB program, this 2 parameter is already known, how can I pass this 2 fields to the access query, so that it exports the table without asking for user input? I will appreciate your help very much. Thankyou.
Sub ExportToExcel()
Dim acApp As Access.Application
Dim exApp As Excel.Application
On Error GoTo errExportToExcel
Screen.MousePointer = vbHourglass
Set acApp = CreateObject("Access.Application"
acApp.Application.OpenCurrentDatabase "Placements.mdb"
acApp.DoCmd.TransferSpreadsheet acExport, 8, "Placements", "Placements.xls", True, ""
Set exApp = CreateObject("Excel.Application"
exApp.Workbooks.Open "Placements.xls"
exApp.Application.Visible = True
exApp.Application.ActiveWorkbook.Activate
Set acApp = Nothing
Set exApp = Nothing
Screen.MousePointer = vbDefault
Exit Sub
End Sub
Santosh