Macro for copying data

R

Roger Bell

Could anyone tell me how I can create a Macro to Copy
data from one field to another in a Data sheet view and
paste the data into another field, without having to
manually select the column, copy and then paste.

Thanks for anyone's help
 
W

Wayne Morgan

One possibility would be to use the double click event of the control that
has the data you want to copy. In the event procedure, you would use
something like:

Me.txtText2 = Me.txtText1

The question is why are you wanting to do this? Are you storing data in two
places? If so, could you just use a query to link tables and retrieve it
from where it currently is? If it's not to store the data in the other
location, but instead is just for display purposes, you could use a
"calculated control". To do that, you would place an equation in the second
control's Control Source that would set it equal to the value of the first
control.

=[txtText1]
 
R

Roger Carlson

I agree with Wayne.

What you are describing is very "spreadsheet-ish" and not very
"database-ish" (if you'll forgive the made up words.) Although spreadsheets
and databases look similar (data stored in rows and columns) they are very
different products meant to be used in very different ways.

If you could describe what you are trying to accomplish, perhaps we could
show you a better way.

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
L

Lynn Trapp

What you are describing is very "spreadsheet-ish" and not very
"database-ish" (if you'll forgive the made up words.)

Roger,
I like those new words. Can I use them? ;-)
 
L

Lynn Trapp

Yeah, I've referred to people "committing spreadsheet" for quite a long time
now, but "spreadsheet-ish" was new one... :)
 
R

Roger

Thanks A better way would be good. What I have is a data
sheet with a field called "Amount Due" and then date
fields for inputing weekly amounts. What I would like is
that when the data is entered for each week, that the
amount due is entered automatically in the respective
date field, to save repetitive typing and if the amount
paid is different to the amount due, then the figure is
overwritten. Thats why I tought of Copy & paste
Thank you for any further advices
 
W

Wayne Morgan

It sounds as if you want to programmatically set the Default Value of the
field. Once this is set, when you start a new record to enter that week's
payment, the Default Value will automatically fill in the amount for you,
but you can change it to whatever you desire.

Since you say that this is a datasheet, I'm going to make a couple of
guesses on your setup. I suspect that you have a main form that lists the
person or loan number with a datasheet as a subform that indicates the
payments. One way of doing the above would be to set the Default Value of
the payment box in the Current event of the main form. This event will run
each time you move from one record to the next (i.e. from one person or loan
number to the next) on the main form. To refer to a control on the subform
you would use syntax similar to:

Me!ctlNameOfSubformControl.Form!txtPayment.DefaultValue =
Me.txtStandardPaymentAmount
 
Top