Copy/Duplicate record problem

SeaRox

Registered User.
Local time
Today, 08:23
Joined
Apr 1, 2008
Messages
29
I created a sub form to track labor hours. I designed it and tested it before I put it in the main form. It is a continuous form. I used the Command Button wizard to insert a button to duplicate the records. It worked better than I had anticipated. I have a default value in the date field that will automatically put in today's date when they add new records. When I hit the duplicate button it copies everyting, except used the default value for the date. Awsome! If they worked two hours on a job yesterday and two hours on the same job today, they could select that record and hit the button and be done. All's well, right!?

When I inserted the subform into the main form for the employees to use, the copy function stopped working. :eek: Now it just inserts a blank record with the previous date. Here is the code, shouldn't be any surprises since the wizard generated it.

Code:
Private Sub Command32_Click()
On Error GoTo Err_Command32_Click

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
    Me.Requery

Exit_Command32_Click:
    Exit Sub

Err_Command32_Click:
    MsgBox Err.Description
    Resume Exit_Command32_Click
    
End Sub

Any ideas? Other methods of duplicating records?
 
I've used this code before and it works fine as long as they have a record selected to copy from. We'll have to see a sample form or something.
 
DB Posted

Here is the portion of the DB. It took a little bit to get it small enough to post.

Thank you for taking the time to look.:) I am really stumped.:confused:
 

Attachments

The problem with continuous forms is that you cannot specifically select a record to copy unless it is either:

A - Already selected by a user
B - Identified by using a uniqe ID

Have you tried stepping through your code?

I get an error on:

DoCmd.RunCommand acCmdSaveRecord

It says that command is not available.

I can't look at your form becuase you disabled right click menus and such and I don't care to spend the time to redo it all.

The problem is somewhere in your form design...for one it looks like it's refreshing constantly. Also the copy button IS working - I put in some test data for a record, moved to the next record, selected my test one and hit copy. It all goes away in the refresh, but it DOES get added to the table. So there was a duplicate entry created, but it doesn't show up on your form. So you've got issues with the form or query.

Also I don't see why you have a bunch of code for command buttons which don't exist on your form that I can see.
 
Success!

Thanks odin1701!:D

I removed the acCmdSaveRecord line and the Me.requery on the WeekOf field.
(and got rid of the code from the other "duplicate record" buttons I tried.) Now it works.
 

Users who are viewing this thread

Back
Top Bottom