duplicate record (1 Viewer)

kitty77

Registered User.
Local time
Today, 11:27
Joined
May 27, 2019
Messages
693
I'm using the following code and it works fine... But when I try to duplicate the record, it does not allow because of the code on current.

How can I allow the duplicate record and keep what I have?

Me.AllowEdits = False
Me.[Label465].Visible = True
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,359
Hi. I'm not sure it's clear what that code has to do with duplicating a record. Are you saying the code to duplicate a record is on a button that becomes disabled because of AllowEdits? If so, you could either avoid using AllowEdits and just lock all the controls individually, or maybe assign a hotkey combo for the duplicate record code.
 

kitty77

Registered User.
Local time
Today, 11:27
Joined
May 27, 2019
Messages
693
Sorry for not being more clear...

That code is on oncurrent so it does not allow edits. I have a button that allows edits. Works fine. But sometimes I may want to duplicate a record and I think the oncurrent code is not allowing it.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,359
Sorry for not being more clear...

That code is on oncurrent so it does not allow edits. I have a button that allows edits. Works fine. But sometimes I may want to duplicate a record and I think the oncurrent code is not allowing it.

Hi. What is not clear is where is this code to duplicate records located and how is it normally executed. As I said earlier though, if it's on a button on the same form, then AllowEdits is probably affecting it, so you'll have to use a different approach.
 

kitty77

Registered User.
Local time
Today, 11:27
Joined
May 27, 2019
Messages
693
So, the form is set to not allow edits and I have a button that allows edits when clicked. I also have a button on the form that duplicates the record but its not allowing it. I guess the form set to not allow edits is the issue.

How can I keep it the way I have it and also allow the duplicate record to happen?
 

GinaWhipp

AWF VIP
Local time
Today, 11:27
Joined
Jun 21, 2011
Messages
5,901
Hmm, in the code to duplicate the record set Allow Edits to True, duplicate the record and then set it back to Allow Edits False. Will happen fast enough that no one will notice.
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:27
Joined
Jan 23, 2006
Messages
15,364
Kitty,

Can you give us some details of why you want to duplicate a record?
Also, it may help readers to understand the details if you provide the code associated with the button and/or a copy of the database.
Good luck with your project.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:27
Joined
Oct 29, 2018
Messages
21,359
So, the form is set to not allow edits and I have a button that allows edits when clicked. I also have a button on the form that duplicates the record but its not allowing it. I guess the form set to not allow edits is the issue.

How can I keep it the way I have it and also allow the duplicate record to happen?

Okay. AllowEdits is not affecting button clicks then, I thought it might. If so, it must be your code. You're probably using DoCmds to duplicate the record. If so, try Gina's suggestion or use an INSERT query instead.
 

Users who are viewing this thread

Top Bottom