Command Button for copy and paste?

G

Guest

I want to creat a command button on a form.
This Command Button button is for copying the data of a field on the same
form and then paste the data to another field on the same form. The
function only works when the user clicks the Command.

Is this possible with MS Access ?
Please help.
thanks
Karen
 
G

Guest

Try this on the OnClick event of the button.

Me.[TextBox2Name] = Me.[TextBox1Name]

If you want to add the data from the first text box to the second one,
instead of replacing it, then try

Me.[TextBox2Name] = Me.[TextBox2Name] & " " & Me.[TextBox1Name]
 
G

Guest

Thanks, Ofer, it did work but for 1x field, probably you knew this. Is it
possible to copy all the fields of one "Column" to the other fields of the
other "column".
Let me elaborate my Form.
I have Form Header and more than 1 field to be copied to the other fields in
the Detail section. I put the CmdBut in the Header, it doesn't work, then I
created in the Detail, but it only updates 1 row, I want all the fields under
that column to be copied to the other column. I hope I've made myself clear.
thanks.

Ofer Cohen said:
Try this on the OnClick event of the button.

Me.[TextBox2Name] = Me.[TextBox1Name]

If you want to add the data from the first text box to the second one,
instead of replacing it, then try

Me.[TextBox2Name] = Me.[TextBox2Name] & " " & Me.[TextBox1Name]

--
Good Luck
BS"D


KarenY said:
I want to creat a command button on a form.
This Command Button button is for copying the data of a field on the same
form and then paste the data to another field on the same form. The
function only works when the user clicks the Command.

Is this possible with MS Access ?
Please help.
thanks
Karen
 
G

Guest

Before trying back up your data.

For that you need to use update query, and then reresh the form
Something like
===============
Docmd.RunSql "UPDATE TableName SET TableName.FieldName = " &
Me.[TextFieldName]
Me.Requery

===============
If the field type is text then change the SQL
Docmd.RunSql "UPDATE TableName SET TableName.FieldName = '" &
Me.[TextFieldName] & "'"

================
Also, you might need to add a filter to the SQL, if you don't want the whole
table to be updated

--
Good Luck
BS"D


KarenY said:
Thanks, Ofer, it did work but for 1x field, probably you knew this. Is it
possible to copy all the fields of one "Column" to the other fields of the
other "column".
Let me elaborate my Form.
I have Form Header and more than 1 field to be copied to the other fields in
the Detail section. I put the CmdBut in the Header, it doesn't work, then I
created in the Detail, but it only updates 1 row, I want all the fields under
that column to be copied to the other column. I hope I've made myself clear.
thanks.

Ofer Cohen said:
Try this on the OnClick event of the button.

Me.[TextBox2Name] = Me.[TextBox1Name]

If you want to add the data from the first text box to the second one,
instead of replacing it, then try

Me.[TextBox2Name] = Me.[TextBox2Name] & " " & Me.[TextBox1Name]

--
Good Luck
BS"D


KarenY said:
I want to creat a command button on a form.
This Command Button button is for copying the data of a field on the same
form and then paste the data to another field on the same form. The
function only works when the user clicks the Command.

Is this possible with MS Access ?
Please help.
thanks
Karen
 
G

Guest

Thanks for reminding me for the backup, almost forgot !
I'll have to try this tomorrow in the office.
its late in the evening here.
karen

Ofer Cohen said:
Before trying back up your data.

For that you need to use update query, and then reresh the form
Something like
===============
Docmd.RunSql "UPDATE TableName SET TableName.FieldName = " &
Me.[TextFieldName]
Me.Requery

===============
If the field type is text then change the SQL
Docmd.RunSql "UPDATE TableName SET TableName.FieldName = '" &
Me.[TextFieldName] & "'"

================
Also, you might need to add a filter to the SQL, if you don't want the whole
table to be updated

--
Good Luck
BS"D


KarenY said:
Thanks, Ofer, it did work but for 1x field, probably you knew this. Is it
possible to copy all the fields of one "Column" to the other fields of the
other "column".
Let me elaborate my Form.
I have Form Header and more than 1 field to be copied to the other fields in
the Detail section. I put the CmdBut in the Header, it doesn't work, then I
created in the Detail, but it only updates 1 row, I want all the fields under
that column to be copied to the other column. I hope I've made myself clear.
thanks.

Ofer Cohen said:
Try this on the OnClick event of the button.

Me.[TextBox2Name] = Me.[TextBox1Name]

If you want to add the data from the first text box to the second one,
instead of replacing it, then try

Me.[TextBox2Name] = Me.[TextBox2Name] & " " & Me.[TextBox1Name]

--
Good Luck
BS"D


:

I want to creat a command button on a form.
This Command Button button is for copying the data of a field on the same
form and then paste the data to another field on the same form. The
function only works when the user clicks the Command.

Is this possible with MS Access ?
Please help.
thanks
Karen
 

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