Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2006

Tip: Looking for answers? Try searching our database.

RecordsetClone to copy a record/referencing other forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christian ><> - 29 Jun 2006 23:38 GMT
I to duplicate a record (everything but the key field).  If I use the
following code for my button in the form that I am duplicating, then it works:

   If Me.NewRecord Then
       MsgBox "You are on a new record." & _
       "Select the record to duplicate."
   
   Else
       With Me.RecordsetClone
       .AddNew
           ![JWO_Date of Order] = Me.[JWO_Date of Order]
           ![JWO_Job Type] = Me.[JWO_Job Type]
           ![JWO_Customer's Order Number] = Me.[JWO_Customer's Order Number]
           ![JWO_Subcontract Number] = Me.[JWO_Subcontract Number]
           ![JWO_Customer] = Me.[JWO_Customer]
           ![CU_Customer Address] = Me.[CU_Customer Address]
           ![CU_Customer City] = Me.[CU_Customer City]
           ![CU_Customer State] = Me.[CU_Customer State]
           ![CU_Customer Postal Code] = Me.[CU_Customer Postal Code]
           ![CU_Customer Phone Number] = Me.[CU_Customer Phone Number]
           ![CU_Customer Fax Number] = Me.[CU_Customer Fax Number]
           ![JWO_Contact] = Me.[JWO_Contact]
           ![JWO_Project Manager] = Me.[JWO_Project Manager]
           ![PM_Cell Phone Number] = Me.[PM_Cell Phone Number]
           ![PM_E-Mail Address] = Me.[PM_E-Mail Address]
           ![JWO_Project Superintendent] = Me.[JWO_Project Superintendent]
           ![JS_Cell Phone Number] = Me.[JS_Cell Phone Number]
           ![JWO_Project Name] = Me.[JWO_Project Name]
           ![PJ_Address] = Me.[PJ_Address]
           ![PJ_City] = Me.[PJ_City]
           ![PJ_County] = Me.[PJ_County]
           ![PJ_State] = Me.[PJ_State]
           ![PJ_Postal Code] = Me.[PJ_Postal Code]
       
       .Update
       End With
       DoCmd.GoToRecord , , acLast
   End If

However, I want to do it from a button in a DIFFERENT form so I added this
code to the beginning:

   Forms("Job Work Orders Form").SetFocus

But I get an error:

You entered an expression that has an invalid reference to the
RecordsetClone property.

How do I get the code to reference the main form so that it will work?
Ken Snell (MVP) - 30 Jun 2006 02:49 GMT
First, a clarifying question....

You want to run this code in the second form. But are you adding the
duplicated data to that second form's recordset, or to the first form's
recordset? And which form has the data record that is being used to make the
duplicate?
Signature


       Ken Snell
<MS ACCESS MVP>

>I to duplicate a record (everything but the key field).  If I use the
> following code for my button in the form that I am duplicating, then it
[quoted text clipped - 48 lines]
>
> How do I get the code to reference the main form so that it will work?
Christian ><> - 30 Jun 2006 14:49 GMT
Sorry for the confusion.

The first form is the main form.  The second form is strictly buttons (like
a toolbar).  All of the work or data is entered into the first form.  If
someone wants to print, search, delete, etc. a record in the first form, they
click a button in the second.

So in this instance, if there is a job that is almost exactly like one
previously entered in the first form, I want to be able to duplicate that
record in that form by clicking a button in the second.

Clear as mud?

> First, a clarifying question....
>
[quoted text clipped - 54 lines]
> >
> > How do I get the code to reference the main form so that it will work?
Marshall Barton - 30 Jun 2006 16:48 GMT
Christian wrote:

>I to duplicate a record (everything but the key field).  If I use the
>following code for my button in the form that I am duplicating, then it works:
[quoted text clipped - 46 lines]
>
>How do I get the code to reference the main form so that it will work?

You must replace all references to Me with a reference to
the form you are operating on.

Dim frm As Form
Set frm = Forms("Job Work Orders Form")

   If frm.NewRecord Then
       MsgBox "You are on a new record." & _
       "Select the record to duplicate."
   
   Else
       With frm.RecordsetClone
       .AddNew
           ![JWO_Date of Order] = frm.[JWO_Date of Order]
            . . .
Signature

Marsh
MVP [MS Access]

Christian ><> - 30 Jun 2006 17:17 GMT
That did it.  THANKS SO MUCH!!!!!

> Christian wrote:
>
[quoted text clipped - 64 lines]
>             ![JWO_Date of Order] = frm.[JWO_Date of Order]
>             . . .
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.