Duplicate Record Problems

SeaRox

Registered User.
Local time
Today, 04:42
Joined
Apr 1, 2008
Messages
29
My duplicate record button works perfectly when the form is open seperately. When I open the form as a sub form the button no longer functions properly. It creates a new record but it doesn't copy any of the information.

I have tried changing the code but to no avail. See code below.

This is the code that works with the sub form open seperately:
Code:
Private Sub Duplicate_Click()
On Error GoTo Err_Duplicate_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_Duplicate_Click:
    Exit Sub

Err_Duplicate_Click:
    MsgBox Err.Description
    Resume Exit_Duplicate_Click
    
End Sub

This is what I tried various version of:
Code:
Private Sub Duplicate_Click()
On Error GoTo Err_Duplicate_Click


    Me!MainForm.SubForm.DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    Me!MainForm.SubForm.DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
    Me!MainForm.SubForm.DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_Duplicate_Click:
    Exit Sub

Err_Duplicate_Click:
    MsgBox Err.Description
    Resume Exit_Duplicate_Click
    
End Sub

Any ideas?
 
What you're doing doesn't make sense to me. Why are you duplicating a record?

A subform and form are almost always related in some manner.

Using the menu controls obfuscate what you're doing.

Opening a form containing a subform control opens the subform. The subform even opens first.
 
llkhoutx,

I am tracking labor hours and the job, project, customer, etc. are all the same. The only things that change are the date and number of hours worked on each job. It will greatly speed data entry for the employees if they can copy records and just change the hours they worked.

I can't explain the menu controls more than they are the code that is generated when you insert a "duplicate record" button from the button insertion wizard.

It works great when the subform is opened by itself. I put some code in the default value for the date field and when this code copies the record it copies everything but uses the default value for the date. So, if an employee worked on a project for two hours yesterday and two hours today, instead of inputting all the information again. All they do is select the record and hit the "Duplicate" button and they are done.

Can I do this with other code that will work when the form is used as a subform?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom