Results 1 to 13 of 13
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273

    Code not working on other computers

    Hello All,

    I'm having trouble with a bit of code, I'm hoping someone knows what is going on.
    The purpose is to close a form, then open again to a new record with the same information as the previous record. From there, the user will only have to make a small change to one field, rather than entering everything from the beginning.

    Private Sub cmdDup_Click()
    Dim strForm As String
    strForm = "frmTireInvDetail"



    DoCmd.Save acForm, strForm
    DoCmd.GoToRecord , strForm, acNewRec



    Me.Qty = Me.dupQty
    Me.Mfr = Me.dupMfg
    Me.Mdl = Me.dupMdl
    Me.Size = Me.dupSize
    Me.DOT = Me.dupDOT
    Me.RecDt = Me.dupRecDt
    Me.Cmnt = Me.dupCmnt
    Me.Locn.SetFocus

    End Sub

    The Me.dup fields are all DLookup references of the previous record.
    Everything works exactly the way I want it...on my computer. On the computers of the 3 other users, nothing happens at all. No error messages, the form just sits there like you never clicked anything at all.
    All of the computers are running the latest version of Windows 10, Access 16, all accessing the same server to get to the database. I have checked the Reference Library on my computer, and as far as I can tell, everything looks normal. Doesn't the Reference Library follow the database, so I wouldn't have to check it on the other computers if it works correctly on mine? I don't think it would be anything with the code since it works on my computer.
    Any help would be much appreciated.

  2. #2
    Eugene-LS's Avatar
    Eugene-LS is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2018
    Location
    Murmansk
    Posts
    17
    May be it will help
    Code:
    Public Function Duplicate(frm As Form) As Boolean
    'Make a new record as a duplicate of the current
    Dim i As Integer, n As Integer, v() As Variant, rs As DAO.Recordset
        Duplicate = False
        If frm.NewRecord Then Exit Function
        n = frm.Controls.count - 1          'number of controls
        ReDim v(n)
        On Error Resume Next
        For i = 0 To n                      'old values
            v(i) = frm.Controls(i).Value
        Next i
        DoCmd.GoToRecord acDataForm, frm.Name, acNewRec
        For i = 0 To n                      'old values
            If Not IsEmpty(v(i)) Then frm.Controls(i).Value = v(i)
        Next i
        Duplicate = True
    End Function
    Example of using:
    Code:
    Private Sub CommandDublicateRecord_Click()
        Duplicate Me.Form
    End Sub

  3. #3
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Thanks for the quick reply, I will try it out when I can get to the database.
    Is there something with the code that makes it not work on another computer? I ask, because I have another command button somewhat similar, that also doesn't work on the other computers. I'm hoping not to have to change the code all around when it already works great on my computer.
    Thanks.

  4. #4
    Eugene-LS's Avatar
    Eugene-LS is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2018
    Location
    Murmansk
    Posts
    17
    Quote Originally Posted by NISMOJim View Post
    Thanks for the quick reply, I will try it out when I can get to the database.
    Thanks.
    I did not find anything wrong in your code, maybe problem in something else....

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    Presume the other users have trusted the file or are running it from a trusted location

  6. #6
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Correct, that was set up from the start. All of the other code in the database works fine, just this one, and another that is similar.

  7. #7
    Eugene-LS's Avatar
    Eugene-LS is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2018
    Location
    Murmansk
    Posts
    17
    Ajax, Great idea!
    Thanks!
    NISMOJim see my settings (for example):
    Attached Thumbnails Attached Thumbnails ss01.PNG  

  8. #8
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Correct. The drive that the database is on is already set up as a trusted location on all of the computers, and allowing the trusted locations is checked.

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    not quite sure what you expect to see. You've moved to a new record and the code assigns values - however what are those values? Me.dupQty for example if from the new record - they would be null. Suggest you put a breakpoint in the code and step through.

    you say the purpose is to close a form and then reopen it - I don't see anything that closes a form or reopens it.

    If you are trying to assign the original values suggest use the defaultvalue property in the form beforeupdate event i.e.

    Me.Qty.defaultvalue = Me.Qty

  10. #10
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Yeah, that may have been an easier way to do it. The reason I posted is not because the code doesn't work at all, it works perfectly on my computer. It saves the original record into the table, then opens the form to a new record with the same data. On that form, users can make a small change to the DOT # or quantity, and save that record too. It works great, and saves lots of time not having to input all of the fields. What I can't figure out is why it doesn't do anything at all on other computers. The data just sits on the open form, and isn't saved to the table. Any idea why this is happening?

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Doesn't the Reference Library follow the database, so I wouldn't have to check it on the other computers if it works correctly on mine?
    Yes up to a point. If the references exist on the other computers, all should be fine.
    There shouldn't be any issues with version specific references as all using the same Win/Access versions
    There might be an issue if you have used a non-standard reference.

    If you are using any ActiveX controls, you need to be aware that other users may have disabled these
    Similarly some ActiveX controls don't work in 64-bit Office
    Neither of those issues would necessarily trigger error messages
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    All I did was add unbound textboxes to the form with a DLookup to get the values from the previous record. All the code does, is assign the field that will be written to the table, the same value as the DLookup value. I'm usually pretty consistent with doing things the hard way due to my ignorance, but there really isn't anything too complicated going on with the form or the code. If the other computers recognize all of the other code associated with the database, including DLookups in other places, what is so different about this little bit? I'm completely stumped!

  13. #13
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    I finally got a chance to play on one of the computers that doesn't run the code. After four attempts with the command button (still not doing anything at all), it finally threw me a run time error 2501, won't save.
    In researching the error, I've been looking into the Me.Dirty thing. I don't claim to understand it at all, but some of what I read said I could add
    If Me.Dirty Then Me.Dirty = False
    to the beginning of the code I posted above, and it will force save the form. I still don't understand why the other computers might need this extra kick start to save the form and open a new record, but at this point I'm willing to give it a try. I won't get a chance to add the code until tonight, but wanted your ideas/input on if this might work, and why.
    Thank you all for your help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-14-2017, 10:07 AM
  2. Replies: 1
    Last Post: 12-17-2016, 08:18 PM
  3. Replies: 2
    Last Post: 08-26-2013, 11:29 AM
  4. Replies: 6
    Last Post: 07-19-2013, 01:50 PM
  5. Replies: 2
    Last Post: 08-31-2012, 10:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums