Solved

Transfer One Record into New Table and Delete in Old Table

Posted on 2006-11-15
3
137 Views
Last Modified: 2010-04-30


I need the Access form and when you click the"YES" I need to have the one RECORD to transfer the reocrd into a different table and Delete in the present table. Just the Record you are on.  Is this possible?
'//////////////////////////////////////
Private Sub cmdTransferToTable1_Click()
Dim iResponse As Integer

  iResponse = MsgBox("Are You Sure?", vbYesNoCancel, "Processing")

  Select Case iResponse
 
    Case vbYes

'//////////////////

Any help would greatly be appreciate!!


0
Comment
Question by:ca1358
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
Comment Utility
First, run an append query that adds the record from the 'present table' into the 'different table'.
Second, run a delete query that deletes the record from the 'present table'.

Better, bundle both actions into a transaction such that they both succeed or fail together.

{using ado}

Dim cn as adodb.connection
Set cn = 'Need more info here.

With cn
  .BeginTrans
 
  .Execute "INSERT INTO tblDifferent (foo) SELECT blah FROM tblPresent WHERE ID=" & SomeID
  .Execute "DELETE FROM tblPresent WHERE ID=" & SomeID

  If err.number=0 then
    .CommitTrans
  Else
    .RollbackTrans
  End IF
End With
0
 

Author Comment

by:ca1358
Comment Utility
Thank you!
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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