Results 1 to 10 of 10
  1. #1
    Eljefegeneo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    14

    Run Time Error 5, Invalid procedure call or argument

    When I run the code below on one of my computers, it works fine. In fact I have tested it on several other computers, all running either Windows 7 Pro and Windows 7 Home Premium. Some of the computers running 7 Pro are 32 bit, some 64 bit. The 7 Home is 64bit. Unfortunately on the computer (running Home Premium 64 bit) where I do most of my development work the code brings up “Run Time Error 5, Invalid procedure call or argument”.


    The code is for a memo field called “Notes” that is the adding date and username stamp. Before I added the On Error Resume Next, it would always bring up the error message when I tried to edit the memo field. After inserting the On Error Resume Next, it worked, but not on the one computer. Is this just at a gremlin on this particular computer? Or is there some better code to use than the On Error Resume Next? I am developing the DB for work use and at least six people will be using it; don’t want one or more to have the same problem.

    My code:
    Private Sub Notes_AfterUpdate()
    On Error Resume Next
    If Notes = "" Or IsNull(Me.Notes.OldValue) Then
    Me.Notes = Date & " " & Me.Notes & " " & User1
    Else
    Me.Notes = Left(Me.Notes, Len(Me.Notes.OldValue)) & _
    " " & Date & " " & Right(Me.Notes, Len(Me.Notes) - Len(Me.Notes.OldValue)) & " " & User1

    Me.Dirty = False
    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    What line(s) errors? You'll need to comment out the On Error line. Offhand, I wouldn't have thought the OldValue would work in the after update event.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The OldValue property holds the original value until the record is updated/committed, at least according to http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    So something else is happening and need to know which line triggers the error.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Duh; I had the form's after update event in my head, not a control's.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Eljefegeneo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    14
    I am not exactly sure what you mean, but the code after "else" is highlighted. The funny problem is that the code works on other computers, just not the one I use most of the time. That is, On Error Resume Next works fine except on one computer. I tried some other On error codes, but they give the same result. The code works fine except when you try to edit old data. Then the error message occurs, the On Error Resume Next command doing nothing. But, it does work on other computers. Gremlins?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    This is a memo type field? Instead of constantly adding text to this field for the same record, why not separate records in a child Notes table? Or consider http://www.fmsinc.com/MicrosoftAcces...tory/Index.asp
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Your error may be here:

    Me.Notes = Left(Me.Notes, Len(Me.Notes.OldValue)) & _
    " " & Date & " " & Right(Me.Notes, Len(Me.Notes) - Len(Me.Notes.OldValue)) & " " & User1

    If if the len() function evaluates to 0 at this point, then you have left(me.notes, 0) which is causing the error. 0 is an invalid argument for left().

    To check this, put: msgbox "Length of oldvalue = " & Len(Me.Notes.OldValue) right before the if notes = "" ... statement.

    John

  8. #8
    Eljefegeneo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    14
    Thanks but it didn't work. All I get are length messages even when just adding new text. When I try to edit old text I still get the error message. I understand what you are showing me in the above, but teh big question remains why this code works on sveral other computers but not the one I am now using. That is, the On Error Resume Next. It that bit of code would function properly, then all would be OK.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Let's take a step back. Why do you have this design anyway? I think it is unconventional and unnecessary. I advise one of the approaches referenced in my previous post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Eljefegeneo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    14

    Finally figured it out.

    Quote Originally Posted by June7 View Post
    Let's take a step back. Why do you have this design anyway? I think it is unconventional and unnecessary. I advise one of the approaches referenced in my previous post.
    I finally figured it out. Seems that somehow the settings in the Under Tools>Options>General was set incorrectly. It must be set the error trapping to "Break on Unhandled Errors". I had it to "break on all errors". Evidently, "on error resume next" doesn't override the "break on all errors" setting.
    So, thank you all for your help. I will look into your suggestions as they are probably more fool (meaning me) proof. It is just that I am very stubborn when I get a problem and have to solve it. Unfortunately this one took almost a week to figure out. The On Error codes that I had been using for other subs were not working that well and now I know.

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

Similar Threads

  1. Invalid Procedure Call or Argument
    By Trojnfn in forum Access
    Replies: 2
    Last Post: 10-29-2012, 01:44 PM
  2. Replies: 9
    Last Post: 08-10-2012, 03:10 AM
  3. Replies: 8
    Last Post: 06-18-2012, 03:49 PM
  4. Invalid Procedure Call
    By neo651 in forum Queries
    Replies: 21
    Last Post: 09-11-2011, 12:58 PM
  5. invalid procedure call
    By johnmerlino in forum Access
    Replies: 5
    Last Post: 12-13-2010, 10:12 AM

Tags for this Thread

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