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. -
-
-
'***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"
-
-
@timleonard - 'DELETE all the Records from the Data Entry Table
-
CurrentDb.Execute "DELETE * FROM [Data Entry]", dbFailOnError
-
-
'Execute an APPEND Query that will dump the Records from [Data Entry1]
-
'into the [Data Entry] Table
-
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "qApdDataEntry1ToDataEntry"
-
DoCmd.SetWarnings True
7 7673 @timleonard - On Error Resume Next
-
CurrentDb.TableDefs.Delete "Data Entry"
-
-
DoCmd.CopyObject , "Data Entry", acTable, "Data Entry1"
@ADezii
Thanks for the fast reply...
I tried the code above, line 2 states the database engine could not lock table because it is in use and line 4 states that "Data Entry" has relationships and cannot be deleted. I should have mentioned that the table "Data Entry" has relationships. Is there a possibility to do this without deleting the table?
@timleonard
Under these conditions, must more information must be known concerning tyhe Data Entry Table, as in: - What Relationships are this Table involved in?
- Is Referential Integrity enforced on the above Relationships?
- Are cascading Deletes enforced on the above Relationships?
@ADezii
Answers to above.
1. The "Data Entry" table shares relationships with two other tables, "Setup" and "Branch #'s"
2. I don't believe I have any Referential Integrity enforced.
3. There is a delete and an update query tied to the table
Hope this is what you were asking, and thank you for the help
@timleonard - 'DELETE all the Records from the Data Entry Table
-
CurrentDb.Execute "DELETE * FROM [Data Entry]", dbFailOnError
-
-
'Execute an APPEND Query that will dump the Records from [Data Entry1]
-
'into the [Data Entry] Table
-
DoCmd.SetWarnings False
-
DoCmd.OpenQuery "qApdDataEntry1ToDataEntry"
-
DoCmd.SetWarnings True
@ADezii
This seems to work...Thanks again for your help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sean Howard |
last post by:
Dear All,
As is my want I need to do something in Access that seems simple but
cannot fathom out.
I have main form with two subforms, both datasheets with an almost
identical table structure....
|
by: Sven Pran |
last post by:
Probably the answer is there just in front of me only awaiting me to
discover it,
but:
1: I want to build a query that returns all records in one table for which
there is no successful "join"...
|
by: Legendary Pansy |
last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting...
|
by: Kuups |
last post by:
Hi!
I have a question is there any way of disabling the Copy, Paste, Delete ?
of a Windows Control Tex Box Right Click Property during runtime ?
Thanks!
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard...
|
by: Brad |
last post by:
Thanks for taking the time to read my question.
I have a split DB and I want to be able to delete the old table, copy an
existing table that is in the back end, rename it, and then make sure
all...
|
by: Kaur |
last post by:
Hi, I have been successful copying a vba code from one of your posts on
how to copy and paste a record by declaring the desired fields that
needs to be copied in form's declaration and creating two...
|
by: jbrumbau |
last post by:
Hi all,
I'm having difficulty catching error 8511, which states:
"Records that Microsoft Office Access was unable to paste have been inserted into a new table called 'Paste Errors' In the...
|
by: Ruth Barn |
last post by:
When I use a standard append query; 50 of the 10 'pass', 40 do not append due to validation rules. But the 10 are still not actually added to the TASK table after the append is run and they do not...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |