Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate record and clear fields

Status
Not open for further replies.

JOD59

Technical User
Dec 17, 2003
39
US
I want to use the "Duplicate record command" to copy information to a new record. I also want to clear a few of the fields when I do so. I have tried this code and it works accept for one problem. It also clears the fields in the original. thanks in advance for any suggestions.



Private Sub cmdDupRecord_Click()
On Error GoTo Err_cmdDupRecord_Click


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

Exit_cmdDupRecord_Click:
Exit Sub
Me.cboDateComplete.Value = 0
Me.tblChargeNo.Value = Null
Me.tblSBSNo.Value = Null

Err_cmdDupRecord_Click:
MsgBox Err.Description
Resume Exit_cmdDupRecord_Click

End Sub
 
Hi
Is this a typo?

Exit_cmdDupRecord_Click:
[bold]Exit Sub[/bold]
Me.cboDateComplete.Value = 0
Me.tblChargeNo.Value = Null
Me.tblSBSNo.Value = Null

 
Remou, not sure what you mean? this is what I tried but this also clears original
 
Hi
It's just that:
Me.cboDateComplete.Value = 0
Me.tblChargeNo.Value = Null
Me.tblSBSNo.Value = Null
Occurs after an Exit Sub, above. So I do not see how it could run. I thought that maybe the Exit Sub should be after, rather than before these lines.

As a PS, what version of Access are you using?
 
Hi Remou, I'm running MSA 2000, the code will run because it comes before End Sub.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top