Re: Queries

Tech-Archive recommends: Fix windows errors by optimizing your registry



So thanks. i am trying yo use this to duplicate the query in a second
database (The tables are in place


So why do I get this error messge


Cannot execute a select query and the queries go in as unrelated
objects (Access 2007)

Dim db As DAO.Database
Set db = OpenDatabase("C:\Test Files\db1 XP.mdb")
Set db2 = OpenDatabase("C:\Test Files\db2 XP.mdb")
Dim qd As DAO.QueryDef
Dim qd2 As DAO.QueryDef
Dim sqltxt As String

For Each qd In db.QueryDefs
sqltxt = qd.SQL
sqltxt = Replace(sqlst, vbCrLf, " ")
sqltxt = Replace(sqlst, " ", " ")
Set qd2 = db.CreateQueryDef((qd.Name"), sqltxt )
qd2.Execute
Next qd



db.Close

On Tue, 11 Nov 2008 09:28:31 -0600, Paul Clement
<UseAdddressAtEndofMessage@xxxxxxxxxxxxxx> wrote:

On Wed, 05 Nov 2008 00:10:08 -0500, James@xxxxxxx wrote:

¤ I am attempting to duplicate an Access database with VB6. I have
¤ successful duplicated the tables...How do I duplicate the queries?

You can list out the QueryDefs using DAO but then you will need to add each of them using DAO
(CreateQueryDef) to the new database.

Dim db As DAO.Database
Set db = OpenDatabase("C:\Test Files\db1 XP.mdb")
Dim qd As DAO.QueryDef

For Each qd In db.QueryDefs
Debug.Print qd.Name
Debug.Print qd.SQL
Next qd

db.Close

http://msdn.microsoft.com/en-us/library/bb243014.aspx


Paul
~~~~
Microsoft MVP (Visual Basic)

.



Relevant Pages

  • Re: DAO takes too much time to link tables
    ... I am trying to link some tables to a back-end database. ... 'Link the tables contained at the given query. ... Dim rst As DAO.Recordset ... Dim success As Boolean ...
    (microsoft.public.access.modulesdaovba)
  • Re: HELP WITH AUTO EXE PROGRAMMING/CODE
    ... Create a separate database for those times when you won't have your database ... create a Query that returns only the Records about which you ... Dim strsubject As String ...
    (comp.databases.ms-access)
  • Re: mailmerge and sql
    ... means that you will not be able to see them in a database you open using the ... I believe you may have to use DAO instead of ADO to ... then creates a View containing a UNION query. ... Dim oCatalog As ADOX.Catalog ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Using a module in a query
    ... > query builder: ... > in modules in your database are visible using the ... > them you will see the custom functions they contain. ... >>Dim WholeWeeks As Variant ...
    (microsoft.public.access.queries)
  • RE: Using query values for field name in table
    ... tblProcedures will be created in the current database. ... Dim dbsGeneralThoracic As Database ... Dim fOpenedDB As Boolean ... > "Proc" is a caption given to acalculated field in the query ...
    (microsoft.public.access.modulesdaovba)