Copy and paste buttons in form

G

Guest

Hi, I am trying to create a copy and paste button in my form. I have a Close
Form button and it works but I am trying to make a copy, paste and
reset/clear buttons in my form. I am trying to make the person entering data
in a form easier with the copy and paste buttons. First, I type/fill the
information in my form but I will be typing same information over and over
again in my form only changing one thing like item code of a product. Can
someone please tell me how I can create a button so that I can copy the
information in the clipboard with copy button and paste (button) it in a new
empty form (its the same form but next page empty entry form).

Buttons:
1. Copy Button
2. Paste Button
3. Clear/reset button

I prefer macro if possible because I am not very good with VB.

Thanks you in advance for all your help.
 
G

Guest

Copy/Paste is an ugly word, but that is not really what you are doing here.
Sorry, but what you want requires VBA. A Macro wont do this, it is too
involved.
The VBA to do this is not that difficult. The example below is not what a
professional would do, but it will get the job done and you will learn a
little VBA from it.

To start, you may need to know how to put VBA in a control event.
Open the form in design view.

Create the button.

Open the Properties dialog either by clicking the properties icon on the
tool bar or right click and select properties form the drop down. The button
needs to be selected when you do either of these.

Select the Events tab.
Click in the On Click box. You will then see a small button with 3 dots.
Click it.
Select Code Builder.
the VBA editor will open with the Sub and End Sub statements for the event
and the cursor positioned on the first line.
Now, you are ready to begin coding.

First, for the Copy button.
You will need one line of code for each text box or other control on your
form where data will be entered. What we are going to do it is use the Tag
property of each control to store the current value of the control in. We
will use that later in the Paste button code. Here are a couple of lines as
example:

Me.Text0.Tag = Me.Text0
Me.Text1.Tag = Me.Text1
etc.

Now for the Paste Button, we will add a new record and paste all the values
from the tag properties of the controls into the control. Here is the code:

docmd.GoToRecord ,,acNewRec
Me.Text0 = Me.Text0.Tag
Me.Text1 = Me.Text1.Tag
etc.
 
G

Guest

Private Sub Command36_Click()
Me.Part_Number0.Tag = Me.Part_Number0
Me.Description1.Tag = Me.Description1
Me.Registration_Number2.Tag = Me.Registration_Number2

I typed this as you had indicated and I only did 3 text field and it doesn't
work. Also do I have to us _ for (Registration_Number)? Please help. I am
not good with VB at all. Also do I need to start with:

Me.Text0.Tag = Me.Text.0 (is the 0 a number or alphabet? and do I need
to us 0 instead of 1 because my first field is an autonumber and I don't want
to copy that)
 
G

Guest

You are takinig it too literally, I only used those as examples. You code
should look more like:
Me.Part_Number.Tag = Me.Part_Number
Me.Description.Tag = Me.Description
Me.Registration_Number.Tag = Me.Registration_Number

This question
Also do I have to us _ for (Registration_Number)?
I don't understand, can you post more detail?
 

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