Copying Records

G

Guest

I have a form for Job Work Orders. I have created a button to copy the
current reccord into a new one, but it doesn't work. I get this error:

"Records that Microsoft Office Access was unable to pase have been inserted
into a new table called 'Paste Errors.'

But it doesn't say what the error is...

Here is my code:

Forms("Job Work Orders Form").SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
 
A

Allen Browne

This code looks like what the wizard generates, but there are lots of
reasons why it can fail.

For example, if the form's RecordSource is a query that uses more than one
table, the append may try to append values to fields from the other tables,
which will fail. Similarly, if there are calculated controls, the append
won't work for them.

A safer approach is to specify the fields you do want to copy. This is also
more flexible, e.g. you can date the the record as today, while duplicating
the other fields.

This article:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
explains how to specify the fields to duplicate. (You can just ignore the
part about duplicating related records in the subform as well.)
 
G

Guest

I entered in the code and customized it to my form. When I click the button,
I get an error:

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

Here is the line that it is referring to:


'Save and edits first
If Me.Dirty Then
Me.Dirty = False
End If
 
G

Guest

I removed the dirty line just to continue to test it and I get another error:

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

Here is my code for that

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]
![JWO_Insurance Company] = Me.[JWO_Insurance Company]
![JWO_Insurance Contact] = Me.[JWO_Insurance Contact]
![IC_Phone Number] = Me.[IC_Phone Number]
![IC_E-Mail Address] = Me.[IC_E-Mail Address]
![JWO_Exterior Start Date] = Me.[JWO_Exterior Start Date]
![JWO_Interior Start Date] = Me.[JWO_Interior Start Date]
![JWO_Description of Work] = Me.[JWO_Description of Work]
![JWO_Date Requested for Final Inspection] = Me.[JWO_Date
Requested for Final Inspection]
![JWO_Invoice Date] = Me.[JWO_Invoice Date]
![JWO_Retainage] = Me.[JWO_Retainage]
![JWO_Permit Number] = Me.[JWO_Permit Number]
![JWO_Map Number] = Me.[JWO_Map Number]
![JWO_Parcel Number] = Me.[JWO_Parcel Number]
![JWO_Date Completed] = Me.[JWO_Date Completed]
![JWO_AFPI Sales Representitive] = Me.[JWO_AFPI Sales
Representitive]
![JWO_Date Warranty Begins] = Me.[JWO_Date Warranty Begins]
![JWO_Prevailing Wage] = Me.[JWO_Prevailing Wage]
![JWO_Time and Material] = Me.[JWO_Time and Material]
![JWO_Firm Quote] = Me.[JWO_Firm Quote]
![JWO_Special Pay Application Form] = Me.[JWO_Special Pay
Application Form]
![JWO_Schedule of Values] = Me.[JWO_Schedule of Values]
![JWO_Tax Exempt] = Me.[JWO_Tax Exempt]
![JWO_Quote Amount] = Me.[JWO_Quote Amount]

.Update
.Bookmark = .LastModified
lngID = !OrderID
Me.Bookmark = .LastModified
End With
 
A

Allen Browne

The form will have a Dirty property unless it it unbound.
Similarly, an unbound form lacks a RecordsetClone.

Your original post stated you have a form for Job Work Orders.
I assumed this form was bound to a table where you store your job work
orders. My suggestion will not work if the form is not bound to a table. A
paste append would also be meaningless.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Christian > said:
I removed the dirty line just to continue to test it and I get another
error:

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

Here is my code for that

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]
![JWO_Insurance Company] = Me.[JWO_Insurance Company]
![JWO_Insurance Contact] = Me.[JWO_Insurance Contact]
![IC_Phone Number] = Me.[IC_Phone Number]
![IC_E-Mail Address] = Me.[IC_E-Mail Address]
![JWO_Exterior Start Date] = Me.[JWO_Exterior Start Date]
![JWO_Interior Start Date] = Me.[JWO_Interior Start Date]
![JWO_Description of Work] = Me.[JWO_Description of Work]
![JWO_Date Requested for Final Inspection] = Me.[JWO_Date
Requested for Final Inspection]
![JWO_Invoice Date] = Me.[JWO_Invoice Date]
![JWO_Retainage] = Me.[JWO_Retainage]
![JWO_Permit Number] = Me.[JWO_Permit Number]
![JWO_Map Number] = Me.[JWO_Map Number]
![JWO_Parcel Number] = Me.[JWO_Parcel Number]
![JWO_Date Completed] = Me.[JWO_Date Completed]
![JWO_AFPI Sales Representitive] = Me.[JWO_AFPI Sales
Representitive]
![JWO_Date Warranty Begins] = Me.[JWO_Date Warranty Begins]
![JWO_Prevailing Wage] = Me.[JWO_Prevailing Wage]
![JWO_Time and Material] = Me.[JWO_Time and Material]
![JWO_Firm Quote] = Me.[JWO_Firm Quote]
![JWO_Special Pay Application Form] = Me.[JWO_Special Pay
Application Form]
![JWO_Schedule of Values] = Me.[JWO_Schedule of Values]
![JWO_Tax Exempt] = Me.[JWO_Tax Exempt]
![JWO_Quote Amount] = Me.[JWO_Quote Amount]

.Update
.Bookmark = .LastModified
lngID = !OrderID
Me.Bookmark = .LastModified
End With

Allen Browne said:
This code looks like what the wizard generates, but there are lots of
reasons why it can fail.

For example, if the form's RecordSource is a query that uses more than
one
table, the append may try to append values to fields from the other
tables,
which will fail. Similarly, if there are calculated controls, the append
won't work for them.

A safer approach is to specify the fields you do want to copy. This is
also
more flexible, e.g. you can date the the record as today, while
duplicating
the other fields.

This article:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
explains how to specify the fields to duplicate. (You can just ignore the
part about duplicating related records in the subform as well.)
 
G

Guest

Sorry. It's actually bound to a query (in order for the auto fill in stuff
to work). does that help?

Allen Browne said:
The form will have a Dirty property unless it it unbound.
Similarly, an unbound form lacks a RecordsetClone.

Your original post stated you have a form for Job Work Orders.
I assumed this form was bound to a table where you store your job work
orders. My suggestion will not work if the form is not bound to a table. A
paste append would also be meaningless.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Christian > said:
I removed the dirty line just to continue to test it and I get another
error:

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

Here is my code for that

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]
![JWO_Insurance Company] = Me.[JWO_Insurance Company]
![JWO_Insurance Contact] = Me.[JWO_Insurance Contact]
![IC_Phone Number] = Me.[IC_Phone Number]
![IC_E-Mail Address] = Me.[IC_E-Mail Address]
![JWO_Exterior Start Date] = Me.[JWO_Exterior Start Date]
![JWO_Interior Start Date] = Me.[JWO_Interior Start Date]
![JWO_Description of Work] = Me.[JWO_Description of Work]
![JWO_Date Requested for Final Inspection] = Me.[JWO_Date
Requested for Final Inspection]
![JWO_Invoice Date] = Me.[JWO_Invoice Date]
![JWO_Retainage] = Me.[JWO_Retainage]
![JWO_Permit Number] = Me.[JWO_Permit Number]
![JWO_Map Number] = Me.[JWO_Map Number]
![JWO_Parcel Number] = Me.[JWO_Parcel Number]
![JWO_Date Completed] = Me.[JWO_Date Completed]
![JWO_AFPI Sales Representitive] = Me.[JWO_AFPI Sales
Representitive]
![JWO_Date Warranty Begins] = Me.[JWO_Date Warranty Begins]
![JWO_Prevailing Wage] = Me.[JWO_Prevailing Wage]
![JWO_Time and Material] = Me.[JWO_Time and Material]
![JWO_Firm Quote] = Me.[JWO_Firm Quote]
![JWO_Special Pay Application Form] = Me.[JWO_Special Pay
Application Form]
![JWO_Schedule of Values] = Me.[JWO_Schedule of Values]
![JWO_Tax Exempt] = Me.[JWO_Tax Exempt]
![JWO_Quote Amount] = Me.[JWO_Quote Amount]

.Update
.Bookmark = .LastModified
lngID = !OrderID
Me.Bookmark = .LastModified
End With

Allen Browne said:
This code looks like what the wizard generates, but there are lots of
reasons why it can fail.

For example, if the form's RecordSource is a query that uses more than
one
table, the append may try to append values to fields from the other
tables,
which will fail. Similarly, if there are calculated controls, the append
won't work for them.

A safer approach is to specify the fields you do want to copy. This is
also
more flexible, e.g. you can date the the record as today, while
duplicating
the other fields.

This article:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
explains how to specify the fields to duplicate. (You can just ignore the
part about duplicating related records in the subform as well.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have a form for Job Work Orders. I have created a button to copy the
current reccord into a new one, but it doesn't work. I get this error:

"Records that Microsoft Office Access was unable to pase have been
inserted
into a new table called 'Paste Errors.'

But it doesn't say what the error is...

Here is my code:

Forms("Job Work Orders Form").SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append
 
A

Allen Browne

If the form is bound to a Query, it should have a Dirty property and a
RecordsetClone.

Something else is happening here.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Christian > said:
Sorry. It's actually bound to a query (in order for the auto fill in
stuff
to work). does that help?

Allen Browne said:
The form will have a Dirty property unless it it unbound.
Similarly, an unbound form lacks a RecordsetClone.

Your original post stated you have a form for Job Work Orders.
I assumed this form was bound to a table where you store your job work
orders. My suggestion will not work if the form is not bound to a table.
A
paste append would also be meaningless.

Christian > said:
I removed the dirty line just to continue to test it and I get another
error:

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

Here is my code for that

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]
![JWO_Insurance Company] = Me.[JWO_Insurance Company]
![JWO_Insurance Contact] = Me.[JWO_Insurance Contact]
![IC_Phone Number] = Me.[IC_Phone Number]
![IC_E-Mail Address] = Me.[IC_E-Mail Address]
![JWO_Exterior Start Date] = Me.[JWO_Exterior Start
Date]
![JWO_Interior Start Date] = Me.[JWO_Interior Start
Date]
![JWO_Description of Work] = Me.[JWO_Description of
Work]
![JWO_Date Requested for Final Inspection] =
Me.[JWO_Date
Requested for Final Inspection]
![JWO_Invoice Date] = Me.[JWO_Invoice Date]
![JWO_Retainage] = Me.[JWO_Retainage]
![JWO_Permit Number] = Me.[JWO_Permit Number]
![JWO_Map Number] = Me.[JWO_Map Number]
![JWO_Parcel Number] = Me.[JWO_Parcel Number]
![JWO_Date Completed] = Me.[JWO_Date Completed]
![JWO_AFPI Sales Representitive] = Me.[JWO_AFPI Sales
Representitive]
![JWO_Date Warranty Begins] = Me.[JWO_Date Warranty
Begins]
![JWO_Prevailing Wage] = Me.[JWO_Prevailing Wage]
![JWO_Time and Material] = Me.[JWO_Time and Material]
![JWO_Firm Quote] = Me.[JWO_Firm Quote]
![JWO_Special Pay Application Form] = Me.[JWO_Special
Pay
Application Form]
![JWO_Schedule of Values] = Me.[JWO_Schedule of Values]
![JWO_Tax Exempt] = Me.[JWO_Tax Exempt]
![JWO_Quote Amount] = Me.[JWO_Quote Amount]

.Update
.Bookmark = .LastModified
lngID = !OrderID
Me.Bookmark = .LastModified
End With

:

This code looks like what the wizard generates, but there are lots of
reasons why it can fail.

For example, if the form's RecordSource is a query that uses more than
one
table, the append may try to append values to fields from the other
tables,
which will fail. Similarly, if there are calculated controls, the
append
won't work for them.

A safer approach is to specify the fields you do want to copy. This is
also
more flexible, e.g. you can date the the record as today, while
duplicating
the other fields.

This article:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
explains how to specify the fields to duplicate. (You can just ignore
the
part about duplicating related records in the subform as well.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have a form for Job Work Orders. I have created a button to copy
the
current reccord into a new one, but it doesn't work. I get this
error:

"Records that Microsoft Office Access was unable to pase have been
inserted
into a new table called 'Paste Errors.'

But it doesn't say what the error is...

Here is my code:

Forms("Job Work Orders Form").SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste
Append
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 

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