Pages

Thursday, December 29, 2011

Create Table Using Query And Add Data To It

If you want to create a new table using SQL query in VBA.

Here is the code-

Sub create_table_using_sql()
DoCmd.SetWarnings (False)
' CREATE TABLE
DoCmd.RunSQL "CREATE TABLE test_table(ID LONG, Name text, Location Text, Sales Long) "
' INSERT DATA
DoCmd.RunSQL "INSERT INTO test_table ([ID] , [Name], [Location] , [Sales]) VALUES(1,'A','DELHI',10) "
RefreshDatabaseWindow
DoCmd.SetWarnings (True)
End Sub


Download Access Database

No comments:

Post a Comment