0
votes

I have following code to run saved query and export data to excel report. How should I change the code if this query is in a different database?

DoCmd.Requery Q_Check_Mismatches
DoCmd.RunSavedImportExport "Export-Q_Check_Mismatches"

I know we can link all relevant tables to current database and then run the query locally. But I need this because of DB size issue.

Appreciate your response

Cheers

Shabar

1
Have you considered "Compacting" the database to reduce its size? That may solve the issue - Katana24
Yes Katana24, But still I am after this setup as I planned to access different DB when running query - shabar
Thax Katana24. Appreciated - shabar
let me know how it goes - Katana24

1 Answers

0
votes

Following code worked for me

Function QueryRun(strDBPath As String, strImportExport As String) 

Dim objAccess As Access.Application 

Set objAccess = CreateObject("Access.Application") 
objAccess.OpenCurrentDatabase 

strDBPath objAccess.DoCmd.RunSavedImportExport strImportExport 
objAccess.CloseCurrentDatabase 
objAccess.Quit 
Set objAccess = Nothing 
End Function 

Cheers

Shabar