I am new to access and VBA so please bare with me on this...I have a table I am upgrading by adding two new fields and renaming three others. Since I have several users using this database I am trying to create an update button that will copy the table from the original database into the new one and then update or copy the records from the old table to the new. I have managed to get it to work, but was wondering if there is an easier way to do it then what is listed below.
Code:
'***Is there an easier way to do this part ***
'***Copy and Paste All Records to new table
DoCmd.OpenTable "Data Entry1", acNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
'*************
DoCmd.OpenTable "Data Entry", acNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdDelete
DoCmd.RunCommand acCmdPaste
DoCmd.OpenTable "Branch #'s1", acNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
'*************
DoCmd.OpenTable "Branch #'s", acNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdDelete
DoCmd.RunCommand acCmdPaste
DoCmd.OpenTable "Setup1", acNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
'*************
DoCmd.OpenTable "Setup", acNormal, acEdit
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdDelete
DoCmd.RunCommand acCmdPaste
'***Close Tables***
DoCmd.Close acTable, "Data Entry1", acSaveNo
DoCmd.Close acTable, "Data Entry", acSaveYes
DoCmd.Close acTable, "Branch #'s1", acSaveNo
DoCmd.Close acTable, "Branch #'s", acSaveYes
DoCmd.Close acTable, "Setup1", acSaveNo
DoCmd.Close acTable, "Setup", acSaveYes
'***Deletes Table After Imported***
DoCmd.DeleteObject acTable, "Data Entry1"
DoCmd.DeleteObject acTable, "Branch #'s1"
DoCmd.DeleteObject acTable, "Setup1"
Comment