Link to home
Start Free TrialLog in
Avatar of bill201
bill201

asked on

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

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"

Avatar of Kent Dyer
Kent Dyer
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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