Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
208 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
ID: 40215417
What records are being compared?
0
 

Author Comment

by:ca1358
ID: 40215429
If the field [CMTID] Matches then export out and then del record in Table1.
0
 
LVL 31

Accepted Solution

by:
hnasr earned 2000 total points
ID: 40215725
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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

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

Author Closing Comment

by:ca1358
ID: 40217380
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 31

Expert Comment

by:hnasr
ID: 40218277
Welcome!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

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