Re: Error:Invalid procedure call or argument

From: Matt Weyland (anonymous_at_discussions.microsoft.com)
Date: 06/18/04


Date: Fri, 18 Jun 2004 10:14:08 -0700


>-----Original Message-----
>"Matt Weyland" <anonymous@discussions.microsoft.com>
wrote in message
>news:1e6a801c4554c$b0b3b7e0$a401280a@phx.gbl
>> I keep getting this error Error number 5 and and Error
>> Number 0 everytiime I execute this code:
>>
>> Private Sub Update()
>> On Error GoTo ErrHand
>> SQL = "UPDATE tblMemo SET subject = " & AddQuotes
>> (mSubject) & "," & _
>> "dateReceived =#" & mDateRcvd & "#, " & _
>> "URL = " & AddQuotes(mQNetURL) & ", " & _
>> "DateEntered = #" & mDateEntered & "#, " & _
>> "ServerLocation =" & AddQuotes(mServerLocation) & _
>> " WHERE MemoID = " & AddQuotes(MemoID)
>>
>> Set DB = CurrentDb
>> DB.Execute SQL, dbFailOnError 'this is where this fails
>> 'Set DB = Nothing
>> ErrHand:
>> 'If Err.Number = 5 Or Err.Number = 0 Then Exit Sub
>> 'Stop
>> Err.Raise Err.Number, Err.Source, Err.Description
>> MsgBox "Error: Class: Memo" & vbCrLf & "Method: Private-
>> Insert" & vbCrLf & Err.Number & ":" & Err.Description
>>
>>
>> End Sub
>>
>> I can't seem to figure out why this keeps occuring.
>> Following is an example of the completed SQL string.
Which
>> when pasted into the SQL designer executes with no
errors,
>> and the code is updating the source table eventhough
this
>> is returning an error.
>>
>> UPDATE tblMemo SET subject = "This is the
>> subject",dateReceived =#6/16/2004#, URL = "fff",
>> DateEntered = #6/16/2004 6:29:35 PM#, ServerLocation
>> ="C:\Work\Training Document.doc" WHERE MemoID = "04-125-
CA"
>>
>> I duplicated this code across several classes and it
>> everyone is generating the same error. I am quite sure
>> that I have the correct libraries referenced, but can't
>> seem to figure this out.
>>
>> Any assistance anyone can provide on this will be
greatly
>> appreciated.
>
>Because you have no Exit Sub statement before your error-
handling code,
>the sequence of execution "falls through" to that error
handler even
>when no error has occured. Then your error-handling code
tries to raise
>error 0, which is not valid and causes error 5 (invalid
procedure call
>or argument), and then your own message is displayed
showing error 0.
>
>Change it like this:
>
>'----- start of revised part of code -----
> Set DB = CurrentDb
> DB.Execute SQL, dbFailOnError
>
>Exit_Point:
> Set DB = Nothing
> Exit Sub
>
>ErrHand:
> MsgBox _
> "Error: Class: Memo" & vbCrLf & "Method: Private-
Insert" & _
> vbCrLf & Err.Number & ":" & Err.Description
>
> Err.Raise Err.Number, Err.Source, Err.Description
> Resume Exit_Point
>
>End Sub
>
>'----- end of revised part of code -----
>
>
>--
>Dirk Goldgar, MS Access MVP
>www.datagnostics.com
>
>(please reply to the newsgroup)
>
>
>.
>

You are a gem, this totally fixed my problem and all is
working with no error.

This has been something I have been dealing with over the
past three days.

Thanks once again.



Relevant Pages

  • Re: Simple Insert Into...
    ... it is in a control on the form; and is unbound (it's actually a combo ... box that is used as a dropdown list, values taken from a different table; SQL ... I need this value to assign a unique ID to the entire recordset being ... In your form's Sub, you'll wind up with something like the following: ...
    (microsoft.public.access.modulesdaovba)
  • Re: Simple Insert Into...
    ... You can store unbound control data in a variable, ... in the sql. ... Dim strSQL As String ... In your form's Sub, you'll wind up with something like the following: ...
    (microsoft.public.access.modulesdaovba)
  • Re: Make Table Query
    ... Sub GetExcelFiles(strAccess as string, strDir as string) ... ' strDir - name of the directory to get Excel files. ... Looking at your reply I think I can insert the SQL piece into code ...
    (microsoft.public.access.queries)
  • Re: On Close -- use UnLoad -- oops!
    ... CurrentDb.Execute strSQL, dbFailOnError ... MVP Microsoft Access ... CTRL-G to Goto the debuG window -- look at the SQL statement ... Private Sub Form_Close ...
    (microsoft.public.access.formscoding)
  • Re: search by 1 of 3 combos
    ... I guess I should expand a bit on an example of what you can do with modifying SQL for a search combo... ... , mWhere as string ... Dim mRecordID As Long ... Private Sub cmd_search_Click ...
    (microsoft.public.access.formscoding)