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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplication of record

Status
Not open for further replies.

Dophia

Technical User
Jul 26, 2004
263
CA
Hi Everyone:

I have a form on which there was a "duplicate record" button, created with the wizard. Now it now longer works.The error is that the "append/paste is not available now". But, if I go into the query, I can copy and paste a new record, after I change the primary key's value.

Can anyone suggest what could be happening to stop the duplication?

Sophia
 
Dophia . . .

The code sets the defaults of the textboxes to the values of the currently selected record. From that point when you go to edit a record you see the values there until you select another or different record which becomes the new defaults.

If by chance your selecting a new record and hitting the button this wont work. You have to select any previously saved record then hit the button . . .

If your still having a problem remove the [blue]?[/blue] from the primarykey (shouldn't be there anyway) and test again.

I've given this snippet of code out for many years and I'm curious as to what the problem really is! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Aceman: I added the ? to some more fields, but the only one that duplicates is one of them. So, when I click the button, and then click on "add new record", the one field shows as a duplicate of the previous one. I don't get the error message now that I have added more fields.

I wonder if my db is somehow missing some references, or ????
Sophia
 
Hi Dophia

I see you are still struggling to duplicate the record. He is ia more detailed version of my previous post. This should be put in the onclick event of the duplication (select code when it asks you what you want to assisnt to the on click event.

private sub buttonNAME_CLICK()
Dim strSQL as string
strSQL = "INSERT INTO tablename " & _
"SELECT DISTINCT all the fields separated by commas except the primary" & _
"FROM originating tablename " & _
"WHERE a field in the original table eg recordID = identifying criteria"
DoCmd.RunSQL strSQL

End Sub

If your primary key was for example a numeric 'recordID' then the WHERE part should end up looking something like....

"WHERE recordID = " & me.RecordID

Hope this helps


Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
Anyway, Aceman's code use the Tag property, NOT the SmartTags ...
 
Thanks everyone for your help. Does anyone have any idea why my original duplication button works now? See my post above? I don't want to run into the same problem again. This is too strange!

Sophia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top