To duplicate records (1 Viewer)

fraktest

New member
Local time
Today, 11:24
Joined
Oct 31, 2019
Messages
6
I'm developing a package using Access 2010

I have a Form that contains almost all fields of the Table and is used as main form for data input. With the purpose of speed up the input of similar records, I have put a Button to duplicate the current record; here the code:


Private Sub Comando78_Click()
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.GoToRecord , , acNewRec
DoCmd.RunCommand acCmdPaste
cboGoToProduct = Null
End Sub



The button works properly when the application is used with Access 2010.
But when I do create a package using Package Sol wizard and the package is used through MS Access Runtime, the click on duplicate record button produce a Runtime error and the package shut down.

Is there anything wrong in my code?
Please note that the row 'cboGoToProduct = Null' is just to clear a combo box that is filled with characters when I click duplicate records button and the runtime error occours with or without that code row


Thanks for any advise.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:24
Joined
Oct 29, 2018
Messages
13,738
Hi. When you say it doesn't work with Access Runtime, is that by the same user on the same computer? If not, maybe there's a permission issue since you're code is trying to create a new record.
 

fraktest

New member
Local time
Today, 11:24
Joined
Oct 31, 2019
Messages
6
Hi. When you say it doesn't work with Access Runtime, is that by the same user on the same computer? If not, maybe there's a permission issue since you're code is trying to create a new record.

I have distributed the app to 4 different users on pc's of them; on two PC's the duplicate button works, on other two I have error.
Now I have bought ms office 2016. on access 2016 there is button wizard for record duplicate. I'll try that.
Thanks for your response
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:24
Joined
Oct 29, 2018
Messages
13,738
Good luck! Keep us posted.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:24
Joined
Oct 29, 2018
Messages
13,738
No luck at all; I recognized that ms access 2016 has not package wizard creation at all, thus it is useless for me
Hi. Sorry to hear that. Are you sure it's not a permission thing? You might also try using SQL instead of DoCmd.


On the topic of packaging Wizard, there are third-party apps available for that, if you like doing that. Are you creating a commercial application?
 

vba_php

Forum Troll
Local time
Today, 04:24
Joined
Oct 6, 2019
Messages
2,884
from reading this post, here is an alternate method that might work in runtime:

Code:
'The following routine must be called from a button on the form.

Function AutoFillCurrentRecord

On Error Resume Next

Docmd.GotoRecord acDataForm, Me.Name, acNewRec

Dim c as Control
  Dim rs As Recordset
    Set rs = Me.RecordsetClone

rs.Move([COLOR="Red"]"your criteria field here"[/COLOR])

    Me.Painting = False

      For Each c In Me.Controls
      	If Not TypeOf c Is Label Then[/COLOR]
          c = rs(c.ControlSource)
        End If
      Next c
   
    Me.Painting = True

  rs.Close

Set rs = Nothing

End Function

code taken from here:

https://support.microsoft.com/en-us...-data-from-a-previous-record-automatically-in
 

fraktest

New member
Local time
Today, 11:24
Joined
Oct 31, 2019
Messages
6
Hi. Sorry to hear that. Are you sure it's not a permission thing? You might also try using SQL instead of DoCmd.


On the topic of packaging Wizard, there are third-party apps available for that, if you like doing that. Are you creating a commercial application?

Not exactly a commercial; I' m acting as voloonter for my church.
Ok, now I use 'duplicate record' from command button wizard instead the previous code On my work station that works, but yet I have a runtime error on end user PC: 'past action not available now'; thus I think you are right on a permission issue.
Please have you any advise on where to look for that permission issue?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:24
Joined
Oct 29, 2018
Messages
13,738
Not exactly a commercial; I' m acting as voloonter for my church.
Ok, now I use 'duplicate record' from command button wizard instead the previous code On my work station that works, but yet I have a runtime error on end user PC: 'past action not available now'; thus I think you are right on a permission issue.
Please have you any advise on where to look for that permission issue?
Well, for example, can the user manually add a new record?
 

fraktest

New member
Local time
Today, 11:24
Joined
Oct 31, 2019
Messages
6
Well, for example, can the user manually add a new record?

Yes he can; all is working but the duplicate record command: As you said, possibly is a permission matter, that at the moment, I'm to able so solve.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:24
Joined
Oct 29, 2018
Messages
13,738
Yes he can; all is working but the duplicate record command: As you said, possibly is a permission matter, that at the moment, I'm to able so solve.
Hi. If you can't figure it out, he may have to just do it manually then. Good luck!
 

Users who are viewing this thread

Top Bottom