button to copy text and place it in new record

S

Slappy

I need to create a button on a form that will copy the text from a particular
field in a selected record and place the text in the same field for a newly
created record.

In other words...say I have a table with the following fields: 1.
line_number 2. product_type 3. cost. I want to be able to select a line in
the table (say line number "29" with product "pizza" and cost "$10.00") and
press a button and have a new line number created with "pizza" already in the
field for product_type. I presume I can do this with a macro group but I
don't know how to go about setting up the macros. If someone could help it
would be greatly appreciated.
 
K

Ken Snell \(MVP\)

This type of activity is more easily handled with VBA code (in the form's
module) than with a macro, quite honestly. Can you accept the use of VBA for
this situation?
 
S

Slappy

I guess I can, but I've used VBA code only very rarely and I'm a little
intimidated by it. Would it be complicated?
 
K

Ken Snell \(MVP\)

In deference to your desire, here is a way to do it via a macro that is
attached to the On Click property of a command button that you need to put
in the Detail section so that it can be clicked for the desired record:

Action: SetValue
Item: [NameOfPizzaControl].DefaultValue
Expression: [NameOfPizzaControl].Value

Action: GoToRecord
Record: New


If you attach the above macro to the On Click property of the command button
(in a continuous forms view of a form, the button will appear on each
record; click the button on the record that contains the "pizza" value you
want to be used in the new record) that is in the Detail section of the
form, the macro will set the Default Value of the "pizza" control to the
current value, and then it will create a new record -- and you'll see that
"pizza" value in the control in that new record.
--

Ken Snell
<MS ACCESS MVP>
 
S

Slappy

Thanks Ken!



Ken Snell (MVP) said:
In deference to your desire, here is a way to do it via a macro that is
attached to the On Click property of a command button that you need to put
in the Detail section so that it can be clicked for the desired record:

Action: SetValue
Item: [NameOfPizzaControl].DefaultValue
Expression: [NameOfPizzaControl].Value

Action: GoToRecord
Record: New


If you attach the above macro to the On Click property of the command button
(in a continuous forms view of a form, the button will appear on each
record; click the button on the record that contains the "pizza" value you
want to be used in the new record) that is in the Detail section of the
form, the macro will set the Default Value of the "pizza" control to the
current value, and then it will create a new record -- and you'll see that
"pizza" value in the control in that new record.
--

Ken Snell
<MS ACCESS MVP>





Slappy said:
I guess I can, but I've used VBA code only very rarely and I'm a little
intimidated by it. Would it be complicated?
 

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