Craete Table in Current Database

     

    Private Sub CMDButton_Click()
    Dim db As Database
    'to create in current database
    Set db = CurrentDb
    'to create table in another database
    'Set db = OpenDatabase("C:\Users\Pavan\Desktop\Access.accdb")
    Dim tblname As String
    tblname = Me.TxtBox.Value
    db.Execute ("Create Table " & tblname & "([ID] Integer, [Item] text, [Qty] integer, [Price] integer, [Location] string)")
    'DoCmd.RunSQL "CREATE TABLE Employees ([ID] Integer, [Item] text, [Qty] integer, [Price] integer, [Location] string)"
    MsgBox ("Hi Pavan Created Table")
    End Sub