Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 02-22-2006, 05:57 AM
Novice
 
Join Date: Oct 2005
Posts: 13
RHall
Default Copy a record

I would like to call a record using a query to fill a form.

After displaying the data on a form I will change one field and save the record back to the table as a new record.

I have tried several methods and none seems to work.

If I call up the record in edit mode and then save it then I lose the original record.

Here is my question. Does anyone have some code that will perform this operation or direct me to a resource that will help.

Thanks for any assistance.

B Hall
Reply With Quote
  #2  
Old 02-22-2006, 05:54 PM
Expert
 
Join Date: Dec 2005
Location: Wilmington, DE - USA
Posts: 275
matthewspatrick
Send a message via MSN to matthewspatrick
Default

Ideally you would probably want to use an unbound form. I cam up with this pretty quickly to use on a bound form, but it is very inelegant and I would hold out for a better solution if you have the time.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

    With DoCmd
        .SetWarnings False
        .RunSQL "INSERT INTO MyTable (text1, text2, num1, num2) SELECT '" & Me![text1] & _
            "' AS Expr1, '" & Me![text2] & "' AS Expr2, " & Me![num1] & " AS Expr3, " & _
            Me![num2] & " AS Expr4"
        .SetWarnings True
    End With
    Me.Undo
    Cancel = True
    
End Sub
Reply With Quote
  #3  
Old 02-23-2006, 04:40 AM
Novice
 
Join Date: Oct 2005
Posts: 13
RHall
Default copy record

Patrick,

Thanks, I will give it a try.

I found an alternative that is also inelegant.

The concept I was working on is to allow my sales department to have the ability to call up a standard quote, review it, edit it if needed and assign a new quote number.

I created a table that has only the standard quotes. I open that table , retrieve the record required , edit as required, assign a new quote number.

When the salesman clicks on the finished button the record is saved back to its table, and an append query adds the record to the other table that is used for history and printing and emailing of the quote to a customer.

It seems to be working okay but I prefer to do it similar to what you propose.

Bob
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I automatically copy a record entered in one form to another form kabichan Access 0 11-10-2008 09:32 AM
How to move copy queries and reports. Fred C Access 1 11-08-2008 07:24 AM
Need to copy data from one textfield to another? ashiers Forms 0 09-21-2008 09:28 AM
Macro to copy a record and paste within a table? weatheri Access 1 10-27-2006 04:55 AM
Making a backup copy of table or database wasim_sono Access 0 03-09-2006 02:44 AM


All times are GMT -8. The time now is 08:15 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.