Code for Copy/Paste

  • Thread starter Thread starter PD
  • Start date Start date
P

PD

I would like to double-click a text box to select the text and have it
automatically pasted to another text box on the same form.

Any ideas?

Thanks,
 
This isn't hard to do, but I'd be asking why? You shouldn't be looking to
duplicate data...

That said, the answer to your question is:

Assuming 2 textboxes called txt1 and txt2 and when I double-click on txt1 I
would like its value copied to txt2, the code for the double-click would be

Me.txt2 = Me.txt1

it could also be

Me.txt2 = Me.txt2 & Me.txt1

if you wish to keep whatever was already in the textbox and add the info to
the end of it.
 
Thank you Daniel,

The reason...the purpose of this form is two fold. To record a request for
a part number and a lookup for previously requested part numbers. The user
selects a model, that selection populates a subform with previously requested
part numbers for that model. When the requested part number is found in that
subform it needs to be entered as a request. I want this to occur as quickly
as possible, without keystroke if possible.
 
Daniel,

Having trouble with this, I provided incorrect information. The two text
boxes are located on two different subforms. I imagine this changes things?
 
Then you have to explicit select them, the 'me.' will not work

The basic synthax form is

Forms![subform]![subform].Form.[ControlName]

You'd have to try something like

Forms![subformName].Form.[txt2] = Me.txt1
OR
Forms![subformName].Form.[txt2] = Forms![subformName].Form.[txt2] & Me.txt1
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.
 
Daniel,

I tried "Me.PartNumber1 = Forms![RecordDetails].Form.[PartNumber]" and it
would not work. The error message indicates it can not find the form
"RecordDetails". I tried numerous variations with out any luck.

My parent form is "Request Entry", the two subforms are "Part_Lookup"
(contains "PartNumber1") and "RecordDetails" (contains "PartNumber").

"Part_Lookup" subform is a datasheet view sourced from a query, this
contains the part number I want to double-click. "RecordDetails" is a form
view subform sourced from a table, the destination field is a combo box
"PartNumber.

Thanks again!

--
PRD


Daniel Pineault said:
Then you have to explicit select them, the 'me.' will not work

The basic synthax form is

Forms![subform]![subform].Form.[ControlName]

You'd have to try something like

Forms![subformName].Form.[txt2] = Me.txt1
OR
Forms![subformName].Form.[txt2] = Forms![subformName].Form.[txt2] & Me.txt1
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



PD said:
Daniel,

Having trouble with this, I provided incorrect information. The two text
boxes are located on two different subforms. I imagine this changes things?
 
Subforms can be a nasty beast because when you insert them they do not
necesaarily have the same controlname as the actual form.

Open the main form in design view and then click (once and only once) on the
subform and look at the name that appears in the Formatting toolbar or look
at the properties.

Try this and adjust your code accordingly and let me know.
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



PD said:
Daniel,

I tried "Me.PartNumber1 = Forms![RecordDetails].Form.[PartNumber]" and it
would not work. The error message indicates it can not find the form
"RecordDetails". I tried numerous variations with out any luck.

My parent form is "Request Entry", the two subforms are "Part_Lookup"
(contains "PartNumber1") and "RecordDetails" (contains "PartNumber").

"Part_Lookup" subform is a datasheet view sourced from a query, this
contains the part number I want to double-click. "RecordDetails" is a form
view subform sourced from a table, the destination field is a combo box
"PartNumber.

Thanks again!

--
PRD


Daniel Pineault said:
Then you have to explicit select them, the 'me.' will not work

The basic synthax form is

Forms![subform]![subform].Form.[ControlName]

You'd have to try something like

Forms![subformName].Form.[txt2] = Me.txt1
OR
Forms![subformName].Form.[txt2] = Forms![subformName].Form.[txt2] & Me.txt1
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



PD said:
Daniel,

Having trouble with this, I provided incorrect information. The two text
boxes are located on two different subforms. I imagine this changes things?
--
PRD


:

This isn't hard to do, but I'd be asking why? You shouldn't be looking to
duplicate data...

That said, the answer to your question is:

Assuming 2 textboxes called txt1 and txt2 and when I double-click on txt1 I
would like its value copied to txt2, the code for the double-click would be

Me.txt2 = Me.txt1

it could also be

Me.txt2 = Me.txt2 & Me.txt1

if you wish to keep whatever was already in the textbox and add the info to
the end of it.
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

I would like to double-click a text box to select the text and have it
automatically pasted to another text box on the same form.

Any ideas?

Thanks,
 
Daniel made a slight typo.

The basic syntax is actually

Forms![NameOfParentForm]![NameOfSubformControl].Form![NameOfControlOnSubform]

Based on the information you've provided, it probably should be

Forms![Request Entry]![RecordDetails].Form![PartNumber]

although depending on how you added RecordDetails as a subform, it's
possible that the name of the subform control on the Request Entry form may
be something different than RecordDetails.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PD said:
Daniel,

I tried "Me.PartNumber1 = Forms![RecordDetails].Form.[PartNumber]" and it
would not work. The error message indicates it can not find the form
"RecordDetails". I tried numerous variations with out any luck.

My parent form is "Request Entry", the two subforms are "Part_Lookup"
(contains "PartNumber1") and "RecordDetails" (contains "PartNumber").

"Part_Lookup" subform is a datasheet view sourced from a query, this
contains the part number I want to double-click. "RecordDetails" is a
form
view subform sourced from a table, the destination field is a combo box
"PartNumber.

Thanks again!

--
PRD


Daniel Pineault said:
Then you have to explicit select them, the 'me.' will not work

The basic synthax form is

Forms![subform]![subform].Form.[ControlName]

You'd have to try something like

Forms![subformName].Form.[txt2] = Me.txt1
OR
Forms![subformName].Form.[txt2] = Forms![subformName].Form.[txt2] &
Me.txt1
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



PD said:
Daniel,

Having trouble with this, I provided incorrect information. The two
text
boxes are located on two different subforms. I imagine this changes
things?
--
PRD


:

This isn't hard to do, but I'd be asking why? You shouldn't be
looking to
duplicate data...

That said, the answer to your question is:

Assuming 2 textboxes called txt1 and txt2 and when I double-click on
txt1 I
would like its value copied to txt2, the code for the double-click
would be

Me.txt2 = Me.txt1

it could also be

Me.txt2 = Me.txt2 & Me.txt1

if you wish to keep whatever was already in the textbox and add the
info to
the end of it.
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

I would like to double-click a text box to select the text and have
it
automatically pasted to another text box on the same form.

Any ideas?

Thanks,
 
Thank you for catching that Douglas!

Daniel Pineault




Douglas J. Steele said:
Daniel made a slight typo.

The basic syntax is actually

Forms![NameOfParentForm]![NameOfSubformControl].Form![NameOfControlOnSubform]

Based on the information you've provided, it probably should be

Forms![Request Entry]![RecordDetails].Form![PartNumber]

although depending on how you added RecordDetails as a subform, it's
possible that the name of the subform control on the Request Entry form may
be something different than RecordDetails.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PD said:
Daniel,

I tried "Me.PartNumber1 = Forms![RecordDetails].Form.[PartNumber]" and it
would not work. The error message indicates it can not find the form
"RecordDetails". I tried numerous variations with out any luck.

My parent form is "Request Entry", the two subforms are "Part_Lookup"
(contains "PartNumber1") and "RecordDetails" (contains "PartNumber").

"Part_Lookup" subform is a datasheet view sourced from a query, this
contains the part number I want to double-click. "RecordDetails" is a
form
view subform sourced from a table, the destination field is a combo box
"PartNumber.

Thanks again!

--
PRD


Daniel Pineault said:
Then you have to explicit select them, the 'me.' will not work

The basic synthax form is

Forms![subform]![subform].Form.[ControlName]

You'd have to try something like

Forms![subformName].Form.[txt2] = Me.txt1
OR
Forms![subformName].Form.[txt2] = Forms![subformName].Form.[txt2] &
Me.txt1
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

Daniel,

Having trouble with this, I provided incorrect information. The two
text
boxes are located on two different subforms. I imagine this changes
things?
--
PRD


:

This isn't hard to do, but I'd be asking why? You shouldn't be
looking to
duplicate data...

That said, the answer to your question is:

Assuming 2 textboxes called txt1 and txt2 and when I double-click on
txt1 I
would like its value copied to txt2, the code for the double-click
would be

Me.txt2 = Me.txt1

it could also be

Me.txt2 = Me.txt2 & Me.txt1

if you wish to keep whatever was already in the textbox and add the
info to
the end of it.
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

I would like to double-click a text box to select the text and have
it
automatically pasted to another text box on the same form.

Any ideas?

Thanks,
 
Thank you

That seemed to get me past that hurdle. At present I receive "Record not
updateable".

Your thoughts at your convenience.

--
PRD


Daniel Pineault said:
Thank you for catching that Douglas!

Daniel Pineault




Douglas J. Steele said:
Daniel made a slight typo.

The basic syntax is actually

Forms![NameOfParentForm]![NameOfSubformControl].Form![NameOfControlOnSubform]

Based on the information you've provided, it probably should be

Forms![Request Entry]![RecordDetails].Form![PartNumber]

although depending on how you added RecordDetails as a subform, it's
possible that the name of the subform control on the Request Entry form may
be something different than RecordDetails.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PD said:
Daniel,

I tried "Me.PartNumber1 = Forms![RecordDetails].Form.[PartNumber]" and it
would not work. The error message indicates it can not find the form
"RecordDetails". I tried numerous variations with out any luck.

My parent form is "Request Entry", the two subforms are "Part_Lookup"
(contains "PartNumber1") and "RecordDetails" (contains "PartNumber").

"Part_Lookup" subform is a datasheet view sourced from a query, this
contains the part number I want to double-click. "RecordDetails" is a
form
view subform sourced from a table, the destination field is a combo box
"PartNumber.

Thanks again!

--
PRD


:

Then you have to explicit select them, the 'me.' will not work

The basic synthax form is

Forms![subform]![subform].Form.[ControlName]

You'd have to try something like

Forms![subformName].Form.[txt2] = Me.txt1
OR
Forms![subformName].Form.[txt2] = Forms![subformName].Form.[txt2] &
Me.txt1
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

Daniel,

Having trouble with this, I provided incorrect information. The two
text
boxes are located on two different subforms. I imagine this changes
things?
--
PRD


:

This isn't hard to do, but I'd be asking why? You shouldn't be
looking to
duplicate data...

That said, the answer to your question is:

Assuming 2 textboxes called txt1 and txt2 and when I double-click on
txt1 I
would like its value copied to txt2, the code for the double-click
would be

Me.txt2 = Me.txt1

it could also be

Me.txt2 = Me.txt2 & Me.txt1

if you wish to keep whatever was already in the textbox and add the
info to
the end of it.
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

I would like to double-click a text box to select the text and have
it
automatically pasted to another text box on the same form.

Any ideas?

Thanks,
 
Thank you for all your help. After researching the "Recordset can not be
updated" it dawned on me that the order of the code may be trying to modify
the query based subform. So by switching the order around the = it worked
very well.

Thanks again!
--
PRD


Daniel Pineault said:
Thank you for catching that Douglas!

Daniel Pineault




Douglas J. Steele said:
Daniel made a slight typo.

The basic syntax is actually

Forms![NameOfParentForm]![NameOfSubformControl].Form![NameOfControlOnSubform]

Based on the information you've provided, it probably should be

Forms![Request Entry]![RecordDetails].Form![PartNumber]

although depending on how you added RecordDetails as a subform, it's
possible that the name of the subform control on the Request Entry form may
be something different than RecordDetails.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PD said:
Daniel,

I tried "Me.PartNumber1 = Forms![RecordDetails].Form.[PartNumber]" and it
would not work. The error message indicates it can not find the form
"RecordDetails". I tried numerous variations with out any luck.

My parent form is "Request Entry", the two subforms are "Part_Lookup"
(contains "PartNumber1") and "RecordDetails" (contains "PartNumber").

"Part_Lookup" subform is a datasheet view sourced from a query, this
contains the part number I want to double-click. "RecordDetails" is a
form
view subform sourced from a table, the destination field is a combo box
"PartNumber.

Thanks again!

--
PRD


:

Then you have to explicit select them, the 'me.' will not work

The basic synthax form is

Forms![subform]![subform].Form.[ControlName]

You'd have to try something like

Forms![subformName].Form.[txt2] = Me.txt1
OR
Forms![subformName].Form.[txt2] = Forms![subformName].Form.[txt2] &
Me.txt1
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

Daniel,

Having trouble with this, I provided incorrect information. The two
text
boxes are located on two different subforms. I imagine this changes
things?
--
PRD


:

This isn't hard to do, but I'd be asking why? You shouldn't be
looking to
duplicate data...

That said, the answer to your question is:

Assuming 2 textboxes called txt1 and txt2 and when I double-click on
txt1 I
would like its value copied to txt2, the code for the double-click
would be

Me.txt2 = Me.txt1

it could also be

Me.txt2 = Me.txt2 & Me.txt1

if you wish to keep whatever was already in the textbox and add the
info to
the end of it.
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.



:

I would like to double-click a text box to select the text and have
it
automatically pasted to another text box on the same form.

Any ideas?

Thanks,
 
Back
Top