copy data from one form to another

G

Guest

Hi,

I try to copy some data that is needed on more than one form. Since I do not
want to copy everything I can't use the built-in copy/paste.

My first attempt was to copy the data I need via recordsets from one record
to another. My problem is I finish this operation with the "update" command,
but I do want to give the user the opportunity to rollback this action (like
the built in feature does it if you press ESC before going to another record).

My idea was either to get my code to do this or to create some sub that just
takes all fields on the current form and then inserts the data in the form's
fields.

How can I get all fields on the current form and their data source?

Thanks for your help!
 
G

Guest

One option
You can create Global variable in a module
Global NumField As Long, StrField As String, StrField2 As String ....

Create a button on the form, and assign the values from the form to the
global variables
NumField = Me.NumFieldInForm
StrField = Me.StrFieldInForm
StrField2 = Me.StrField2InForm

On the load event of the second form you can assign the values from the
variables to the fields in the form
Me.NumFieldInForm = NumField
Me.StrFieldInForm = StrField
Me.StrField2InForm = StrField2
 
G

Guest

Thanks. My problem is I do have many forms and do not want to create
variables for all fields.

Without knowing how the fields are called, can I get all of them and for
example put them in an array? That would help a lot...
 

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

Top