We help IT Professionals succeed at work.

how can i in access vba copy a query structure in the same database

bill201
bill201 used Ask the Experts™
on
hi

how can i in vba access copy a structure from query to another table in the same database

for example i want to make a table the the name will be table1 and it's will be emtry but the structure will be like the  in the query "Query1"

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kent DyerIT Security Analyst Senior

Commented:
I think the Copy and/or save as Wizard from Access will prompt whether you will copy the data and/or structure (schema) from one Access db to another.

HTH,

Kent
Database Architect / Application Developer
Top Expert 2007
Commented:
How about this:

    With CurrentDb
        .Execute "SELECT Query1.* INTO Table1 FROM Query1"  'Make the table
        .Execute "DELETE Table1.* FROM Table1" 'delete records
    End With

mx
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:

Put this code in a regular VBA module

Public Function mMakeTable()

    With CurrentDb
        .Execute "SELECT Query1.* INTO Table1 FROM Query1"  'Make the table
        .Execute "DELETE Table1.* FROM Table1" 'delete records
    End With

End Function

Then you can call mMakeTable() from the vba Immediate Window if you like.

mx