C
cleech
Hello all:
I'm working on a function to copy several queries meeting certain
criteria. The following is where I ended up so far with a few
variations. Idealy I would just like to replace AA with BB in the new
query.
I usually get an error message for a type mismatch on the CopyOject
line. Should the NewName variable be declared as querydef or
something else?
Dim db As Database
Dim qdf As QueryDef
Dim NewName As String
Dim ctr As Integer
ctr = 1
Set db = CurrentDb
For Each qdf In db.QueryDefs
If InStr(1, qdf.Name, "_AA") > 2 Then
NewName = "BB" & ctr
DoCmd.CopyObject NewName, acQuery, qdf.Name
Debug.Print qdf.Name
End If
ctr = ctr + 1
Next qdf
Set db = Nothing
Any help is greatly appreciated.
Thanks
I'm working on a function to copy several queries meeting certain
criteria. The following is where I ended up so far with a few
variations. Idealy I would just like to replace AA with BB in the new
query.
I usually get an error message for a type mismatch on the CopyOject
line. Should the NewName variable be declared as querydef or
something else?
Dim db As Database
Dim qdf As QueryDef
Dim NewName As String
Dim ctr As Integer
ctr = 1
Set db = CurrentDb
For Each qdf In db.QueryDefs
If InStr(1, qdf.Name, "_AA") > 2 Then
NewName = "BB" & ctr
DoCmd.CopyObject NewName, acQuery, qdf.Name
Debug.Print qdf.Name
End If
ctr = ctr + 1
Next qdf
Set db = Nothing
Any help is greatly appreciated.
Thanks