invalid procedure call...

the_net_2.0

Banned
Local time
Yesterday, 20:57
Joined
Sep 6, 2010
Messages
812
hello all,

I have been working for a while and cannot fix this small issue. I have the following code and I'm getting the error in the thread title on the line in red. can someone help me out?

Code:
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tagattribsbu")
Dim rs2 As DAO.Recordset
Set rs2 = CurrentDb.OpenRecordset("attribs")
Dim i As Long
Dim strattrib As String
Dim strtag As String
Dim strvalues() As String

rs.MoveLast
rs.MoveFirst

   Do Until rs.EOF
      strvalues() = Split(rs!aValue, " ")
         For i = LBound(strvalues) To UBound(strvalues)
            
            If InStr(strvalues(i), "<") = 0 Or InStr(strvalues(i), ">") = 0 Then
               [COLOR="DarkRed"][COLOR="Red"]strattrib = Left(strvalues(i), InStr(strvalues(i), "=") - 1)[/COLOR][/COLOR]
               strtag = Left(strvalues(i), InStr(strvalues(i), " ") - 1) & ">"
                  
                  If (Len(strattrib) - InStrRev(strattrib, """")) <> InStr(strattrib, """") Then
                     Debug.Print strattrib & "  (need values)"
                  End If
                     If InStr(strvalues(i), "NOEVENTS") > 0 Then
                        CurrentDb.Execute "UPDATE tags SET " & _
                                          "tags.hasevents = 0 WHERE " & _
                                          "tags.tag = '" & strtag & "'"
                     Else
                        CurrentDb.Execute "UPDATE tags SET " & _
                                          "tags.hasevents = -1 WHERE " & _
                                          "tags.tag = '" & strtag & "'"
                     End If
                     
                        rs2.AddNew
                           rs2!Tag = strtag
                           rs2!attrib = strattrib
                        rs2.Update
                  
            End If
         
         Next i
            rs.MoveNext
   Loop
     
rs.Close
rs2.Close

Set rs = Nothing
Set rs2 = Nothing
 
In my notebook I recorded getting that same error on the MID function because I was starting at an invalid point in the string. I believe the first char is at position 1 whereas I tried to start at position zero. Probably the same idea here - Your LEFT function is probably starting illegally at zero (because INSTR returns 0 if the string is not found).

Just a guess.
 
Try using the starting pos in your instr function (e.g instr(1,string,string). Also check that "=" is in the string.
 
yes I'm sorry guys. Once again I worked too long and didn't think about all the possibles that were in the array. The issue was that the 'instr' was looking for values that were not there. Thanks for the help anyway!
 

Users who are viewing this thread

Back
Top Bottom