Copy and paste

D

David Tunstall

Is there any way that on clicking a command button, I can
copy text from txt1, close the form(frm1) that txt1 is
on, and then paste the text into a textbox - txt2 that is
on an open form behind frm1

Many Thanks
David
 
S

SFAxess

You will want to pass the value to an public variable in
a module.

Either create a new module or use an existing one.
Add this code just below the Option statements at the top
of the module:

Public VariableName as Variant

In the first form's code module you can use code like
this to pass the value of your text box into the global
variable then close the form:

Private Sub commandbuttonName_Click()

VariableName=me.text1

Docmd.Close acForm, me.Name
Docmd.OpenForm NameOfFrm2

End Sub

You can add code like this to the Open event of frm2:

Private Sub frm2_Open(Cancel as Integer)

me.txt2=VariableName

End Sub

If you have never coded VBA in Access, this will be very
confusing. If you need more explanation let me know.
 
D

David Tunstall

Thanks for your help,

I'm just not sure when you say "In the first forms code
module".
 
S

SFAxess

To clarify and refer back to your original email,

The one which has the command button is "frm1", and one
that is opened when the button is clicked is "frm2".
Hope that makes more sense.
 

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