Solved

In Access 2007 Is there a way to Export a record into new table and del it in old table.

Posted on 2014-07-23
6
199 Views
Last Modified: 2014-07-24
Is there a way that In Access 2007 if  Table1[CMTID] = Table2[CMTID] then export to Table3 and Del out Table1. Using VBA or Access Query.
0
Comment
Question by:ca1358
  • 3
  • 2
6 Comments
 
LVL 31

Expert Comment

by:Helen_Feddema
Comment Utility
What records are being compared?
0
 

Author Comment

by:ca1358
Comment Utility
If the field [CMTID] Matches then export out and then del record in Table1.
0
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
Comment Utility
Compare with: tables dbo_A, dbo_B, t3. If dbo_A.a=dbo_B.a then write record to t3
Then delete record from dbo_A. Make sure that t3 structure is the same as dbo_A.

Private Sub Command40_Click()
    DoCmd.RunSQL "INSERT INTO t3 SELECT dbo_A.* FROM dbo_A INNER JOIN dbo_B ON dbo_A.a = dbo_B.b;"
    DoCmd.RunSQL "DELETE dbo_A.* FROM dbo_A WHERE dbo_A.a IN (SELECT dbo_B.a FROM dbo_B);"
END Sub

Open in new window

0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:ca1358
Comment Utility
Having trouble with the Delete Statement, Error Syntax error in Delete Statement.  I including a example file.
0
 

Author Closing Comment

by:ca1358
Comment Utility
Thank you , this is my final code

DoCmd.RunSQL "INSERT INTO Table3 ( CMTID )SELECT Table1.CMTID FROM Table1 INNER JOIN Table2 ON Table1.CMTID = Table2.CMTID;"
DoCmd.RunSQL "Delete Table1.CMTID FROM Table1 WHERE [Table1]![CMTID]IN (SELECT Table2.CMTID FROM Table2);"
0
 
LVL 30

Expert Comment

by:hnasr
Comment Utility
Welcome!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now