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"

Microsoft AccessDatabases

Avatar of undefined
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo