How to create a table using CREAT TABLE in MS Access

How can I create the following table using the CREATE TABLE method in MS Access.

UsrMsgUID      AutoNumber, Primary key, indexed
UsrMsg             Text 255
HideUsrMsg      Boolean

Thanks in advance.
Clive BeatonAccess DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MohitPanditCommented:
1. Click the Create tab on the Ribbon to display the icons for creation functionality.
2. Click Query Design in the Queries section.
3. Place below code
CREATE TABLE [Your Table Name)
(
UsrMsgUID AUTOINCREMENT PRIMARY KEY,
UsrMsg CHAR(255),
HideUsrMsg Bit
)

Open in new window

4. Save query
5. Open in design mode and execute

Best Regards
Clive BeatonAccess DeveloperAuthor Commented:
Thanks Mohit.  

I should have been more clear.  I need to run the whole process as a function in VBA as part of an automatic data conversion on client machines.
MohitPanditCommented:
Okay, are you asking for VBA function to create table?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Clive BeatonAccess DeveloperAuthor Commented:
Yes, please.
MohitPanditCommented:
Here you go

Sub CreateTable()
 
     Dim dbs As Database
 
    ' Modify this line to include the path to Your Database Name
    ' on your computer.
    Set dbs = OpenDatabase("C:\Users\mohi\Documents\Database2.accdb")
        
    dbs.Execute "CREATE TABLE Ramlal1 " _
        & "(UsrMsgUID AUTOINCREMENT PRIMARY KEY, " _
        & "UsrMsg CHAR, HideUsrMsg BIT); "
 
    dbs.Close
 
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Clive BeatonAccess DeveloperAuthor Commented:
Perfect.  Thank you very much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.