copy data from one form to another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help in finding the best way to copy data between forms.

I have a form that on opening select's a new record. The form contains 4 sub
forms with many fields across them. I have a requirment to add a copy
function so that once the data has been typed in the form they can press a
button which would do the following,

1.)Copy data from 15 fields on the active form.
2.)Submit the data to the tables.
3.)Refresh the form to display a new record (Blank Fields)
4.)Paste the 15 fields into the correct fields for new record.

My problem is that my VB code works along as the orginal form is still
active as I can copy the data between the two. But in my case the active form
with the data is closed before being able to copy the data.

I believe I need to store the data in a temporary location on in VB (If
Possible), unless someone can think of an alternative.

Hope this makes sense and someone can point me in the right direction.

Martin
 
Hi Martin,

The question is why you need to copy data between forms... but leaving that
aside, you could simply run an SQL query to insert the records into the new
table, then open the new table's form passing the ID as a parameter, then in
the on open event jump to the appropriate record.

eg:
docmd.runsql "insert into TABLENAME(FIELD1, FIELD2) values (" & me.FIELD1 &
", " & me.FIELD2 & ")"
docmd.OpenForm "FORMNAME", acNormal, , , , , me.IDFIELD

Then in the on open event of your second form:
me.recordsetclone.findfirst "ID = " & Me.OpenArgs
me.recordset.bookmark = me.recordsetclone.bookmark

Hope this helps.

Damian.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top