Duplicate record then blank certain fields

A

Angie M.

Hello, I'm using Access 03. I have used the Wizard to create a "duplicate
record" button on my form. After the user clicks the button to dup the
record, they want the [First Name], [Last Name] and fields to be
blank in the new record. The code behind the button is as follows:

Private Sub DupRec_Click()

On Error GoTo Err_DupRec_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

' FORM, FIELD NAME AND PROPERTY - EMPTY GOES HERE?

Exit_DupRec_Click:
Exit Sub
Err_DupRec_Click:
MsgBox Err.Description
Resume Exit_DupRec_Click
End Sub

Also is there a resource you would recommend for beginner programmers? I
basically know what I need here, but don't know where to get the syntax or
object names. THANK YOU.
 
A

Allen Browne

It would be possible to set particular fields to Null in your code after the
paste append:
Me.[SomeField] = Null
Me.[AnotherField] = Null
etc.

However, it would be much tidier to just copy the fields you do want set,
adding those to the RecordsetClone of the form. This also avoids problems
with calculated controls that the wizard code fails on.

For an example, see:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
(You can ignore the 8 lines that duplicate the subform records as well.)
 

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