Copy Button?

  • Thread starter Thread starter grace
  • Start date Start date
G

grace

Hello, I have a form which allows data to be entered in a
subform. The data that is entered is monthly budget data
and is often duplicated for each month.

Is there any way to create a "Copy" button that would
automatically duplicate the data but change the primary
key fields (which are Month/year)?

Thanks, Grace
 
grace,
Code a command button click event:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPasteAppend
[SomeField] = Something
 
Thanks - When you say [SomeField] does that mean the field
that I want to be different. For example, I want the same
data for each month. So would I put [Month]= "August" and
if July's data is displayed it will copy the records and
change the Month field's value to be "August"?

Thanks, Grace
-----Original Message-----
grace,
Code a command button click event:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPasteAppend
[SomeField] = Something

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Hello, I have a form which allows data to be entered in a
subform. The data that is entered is monthly budget data
and is often duplicated for each month.

Is there any way to create a "Copy" button that would
automatically duplicate the data but change the primary
key fields (which are Month/year)?

Thanks, Grace


.
 
Grace,
Yes, you would use your field name
[Month]= "August" in place of my generic code.

But why are you having a field named [Month] with a Month entered as text.

Are you planning on a new table next year? and the year after? Every year
has a July and August in it.

Make the field a Date datatype.
Store a valid date in the field.
Without using an Input Mask, all you would need do is enter 7/2003 (for July
2003).
When you wish to see the months data, Access is smart enough to search
through and return all July 2003 records and leave July 2002 out. So there
is no need to start a new table next year.

Also, it's not a good idea to have a field named 'Month'. Month, like Date,
Name, etc., is an Access reserved word. They should not be used as field
names.

This is from Access help:

Guidelines for naming fields, controls, and objects
** snipped**
When you name a field, control, or object, it's a good idea to make sure the
name doesn't duplicate the name of a property or other element used by
Microsoft Access; otherwise, your database can produce unexpected behavior
in some circumstances. For example, if you refer to the value of a field
called Name in a table NameInfo using the syntax NameInfo.Name, Microsoft
Access displays the value of the table's Name property rather than the value
of the Name field.
* snipped**

Search through the Help files for a list of reserved and keywords.

Hope this helps.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


grace said:
Thanks - When you say [SomeField] does that mean the field
that I want to be different. For example, I want the same
data for each month. So would I put [Month]= "August" and
if July's data is displayed it will copy the records and
change the Month field's value to be "August"?

Thanks, Grace
-----Original Message-----
grace,
Code a command button click event:

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPasteAppend
[SomeField] = Something

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Hello, I have a form which allows data to be entered in a
subform. The data that is entered is monthly budget data
and is often duplicated for each month.

Is there any way to create a "Copy" button that would
automatically duplicate the data but change the primary
key fields (which are Month/year)?

Thanks, Grace


.
 
Back
Top