Hi,
I tried to copy... as what the subject says by coding like the following but I got error "2486" and there was no clear desc as why it was not doable.
As I pressed Debug, it points to the doCmd.CopyObject row. Cannot explain why. All in all, it's a simple process trying to avoid keying in the name of each query.
Thanks in advance.
Sub CopyQueries()
Dim dbs As Database
Dim qdf As QueryDef
Dim objAcc As Object
Set objAcc = New Access.Application
objAcc.OpenCurrentDatabase ("C:\jqz\kmk\MM\CB\LTC_Chargeback.mdb")
Set dbs = CurrentDb
For Each qdf In dbs.QueryDefs
objAcc.DoCmd.CopyObject "C:\jqz\kmk\MM\CB\RESULTS-FEDERAL.mdb", , acQuery, qdf
objAcc.CloseCurrentDatabase
Set objAcc = Nothing
Next
End Sub
I tried to copy... as what the subject says by coding like the following but I got error "2486" and there was no clear desc as why it was not doable.
As I pressed Debug, it points to the doCmd.CopyObject row. Cannot explain why. All in all, it's a simple process trying to avoid keying in the name of each query.
Thanks in advance.
Sub CopyQueries()
Dim dbs As Database
Dim qdf As QueryDef
Dim objAcc As Object
Set objAcc = New Access.Application
objAcc.OpenCurrentDatabase ("C:\jqz\kmk\MM\CB\LTC_Chargeback.mdb")
Set dbs = CurrentDb
For Each qdf In dbs.QueryDefs
objAcc.DoCmd.CopyObject "C:\jqz\kmk\MM\CB\RESULTS-FEDERAL.mdb", , acQuery, qdf
objAcc.CloseCurrentDatabase
Set objAcc = Nothing
Next
End Sub