Copy and Paste Multiple Fields

kitty77

Registered User.
Local time
Today, 16:32
Joined
May 27, 2019
Messages
715
How can I copy multiple fields (say 6 fields) on one form and have them paste in the same fields in another form?

Thanks...
 
Using code or manually? How are these forms related to each other? Are they bound to the same table?
 
Using code or manually? How are these forms related to each other? Are they bound to the same table?
Oh, sorry... Code. They are not related but will be the same name, type, size.
 
You should be able to do something like this in a procedure

Code:
With Forms("Form2Name")
  .ControlName = me.ControlName
  .control2Name = me.Control2Name
  ...
  .Control6Name = me.Control6Name
end with

Where controlName is substituted for your real names.
 
You should be able to do something like this in a procedure

Code:
With Forms("Form2Name")
  .ControlName = me.ControlName
  .control2Name = me.Control2Name
  ...
  .Control6Name = me.Control6Name
end with

Where controlName is substituted for your real names.
Is this the copy or the paste? I don't see the form names? Is controlName the fields?
 
Access is not excel which is why you can't select multiple values from form controls and paste them to a different form. The code MajP offered will work but I would remind you that if you need to do this, it is quite likely that your data is not properly normalized and you have other issued to deal with to fix it. In a Relational Data base, we store data ONCE and ONLY ONCE. Period.
 
I just want to copy and paste. Not exactly sure what you mean.
 
Is this the copy or the paste? I don't see the form names? Is controlName the fields?
Can you explain your example more? Where are the field names, where are the form names?
 
Not exactly sure what you mean.
In a database copying data is not normally done. This usually hints that your tables are not set up correctly. Can you post your database?

In my example the code is both the copy and paste. You could put that in a button event on form 1. It will paste whatever row you are on in form 1 to the corresponding controls in form 2. As said this will work, but it is probably not something that is supporting a correctly designed database.
 
It has nothing to do with the tables being incorrect? I simply want to bring certain info form some fields (from form 1) and put that info into another form (form 2) So, when I'm in form 2, I don't have to reinput the data.
 
I simply want to bring certain info form some fields (from form 1) and put that info into another form (form 2) So, when I'm in form 2, I don't have to reinput the data.
Your tables might be correct, cannot say. But in general when someone want to copy from one form to another it hints that the table design is not correct. The beauty of a DB is that data only needs to be stored once and can be displayed in endless ways. I have built thousands of Access databases and do not recall ever wanting to copy and paste from one form to another. If you want to provide your db we can look at it. There may be a betters solution than copy and paste such as an insert query.
 
As several others have said or implied, you just don't Copy and Paste things in Access. It's not Excel. You might write code to essentially copy values from one form control to another- and MajP already showed how to do that.

Give it a try
 
The code had a line to move to the new record. If you remove it, it will update the current record in Form 2
Code:
'  DoCmd.GoToRecord acDataForm, "Form2", acNewRec
 
The code had a line to move to the new record. If you remove it, it will update the current record in Form 2
Code:
'  DoCmd.GoToRecord acDataForm, "Form2", acNewRec
Perfect!!! Thanks!
 
As long as you're happy but learning how to do this correctly would have been better. It is extremely easy to relate two tables and we would have been happy to show you how and then a query that joins the two tables would show the data where ever you needed it without duplication.
 

Users who are viewing this thread

Back
Top Bottom