Copying Form data

test2000

Registered User.
Local time
Today, 20:57
Joined
Nov 30, 2009
Messages
11
Hi Experts,

I have a few tables which are all linked to a ComponentID via relationships, I use a form to add and edit records, this works nicely.
Though we have an issue that new records are very similar to old ones, so I want to be able to open a form (which is built on a query like when I edit) with an existing records information, then copy it and change a few minor details before saving as a new record,

What would be the best way of doing this? Note that the form is built from a query with table relationships

The edit command I use is;
DoCmd.OpenForm "frmComponent", , , , , acDialog, "Edit"

and the add command I use is
DoCmd.OpenForm "frmComponent", , , , acFormAdd, acDialog, "Add"

So the add command gives a form with blank fields, ideally having that but with existing records information already entered in all the fields (and a different record key) would be great, though I doubt this is possible ( ?)

Any help at all will be greatly appreciated!
 
You're making life unduly complicated, in part, I suspect, because of Access' fickle way of naming things.

When opening a form with

DoCmd.OpenForm "frmComponent", , , , , acDialog, "Edit"

you can edit records and you can add records!

So use your form opened in this way to do both. Then, place a command button on your form to copy a record and follow the Command Button's Wizard in setting it up to copy a record.

If there's chance that you will be trying to copy a newly entered record, before the new record has been saved, you'll need to go into the Access window and, prior to the line to copy the record, explicitly save it, using

If Me.Dirty = True Then Me.Dirty = False
 
TOP MAN! didn't realise that there was a duplicate button, been thinking about this for ages!!! Thanks!

That has fixed my initial issue though within the form there is a list box populated from a query which also requires to be copied which isn't happening at the moment.. any ideas?...

SELECT DISTINCT qryCards.CardtoComponentID, qryCards.Card, qryCards.Card_EOL, qryCards.Description FROM qryCards ORDER BY qryCards.Card;

sql4 = "INSERT INTO tblCardtoComponent(Card_ref,Component_ref)VALUES(" & Value6 & ", " & Value5 & ")"
CurrentDb.Execute sql4, dbFailOnError

where Value5 is the Key. would it be best to use the above and set through adding each line into the new records list?

thanks

Thanks.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom