Copy the Data from one table to another
Public db As Database, tblname As String
Function DefineDatabase()
Set db = CurrentDb
End Function
Function CreateTable()
tblname = Me.TxtboxOutput.Value
db.Execute ("Create Table " & tblname & "([ID] Integer, [Item] Varchar(40), [Qty] integer, [Price] integer, [Location] Varchar(40))")
End Function
Function CloseDatabase()
Set InputRs = Nothing
Set NewTblRs = Nothing
Set db = Nothing
End Function
Private Sub CMD_Transfer_Click()
DefineDatabase
CreateTable
SQL = Me.TxtBoxSQL.Value
Dim InputRs As Recordset
Set InputRs = db.OpenRecordset(SQL)
Dim NewTblRs As Recordset
Set NewTblRs = db.OpenRecordset(tblname)
Do Until InputRs.EOF
NewTblRs.AddNew
NewTblRs.Fields(0).Value = InputRs.Fields(0).Value
NewTblRs.Fields(1).Value = InputRs.Fields(1).Value
NewTblRs.Fields(2).Value = InputRs.Fields(2).Value
NewTblRs.Fields(3).Value = InputRs.Fields(3).Value
NewTblRs.Fields(4).Value = InputRs.Fields(4).Value
NewTblRs.Update
InputRs.MoveNext
Loop
CloseDatabase
End Sub