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
200 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 30

Accepted Solution

by:
hnasr earned 500 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing 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 30

Expert Comment

by:hnasr
ID: 40218277
Welcome!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views 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 Access…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

930 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

16 Experts available now in Live!

Get 1:1 Help Now