Elusive 'Invalid Procedure Call or Argument' Error

G

Guest

I am working in Access 2002 and have a module which abruptly began blowing
up. Testing proves futile since it doesn't compile successfully but instead
provides a mysterious message:
Invalid Procedure Call or Argument
There is no cursor or anything to point out the region of code causing the
error. My code is fairly naive at this point:

Option Explicit
Option Compare Database

Dim dbconn As New ADODB.Connection
Public MyAccount As String
Public MyTextQue As String
Public FullCycle As Boolean

Function Harvest(Name, URL, Tgt as string)
Dim i As Variant

' Prepare to open the web page
Set ie = CreateObject("InternetExplorer.Application")
With ie

.Visible = True
.navigate URL

Do Until Not .Busy
DoEvents
Loop
' Select and copy all of the data from the web page
s = ie.Document.body.innertext
end with 'ie
nstart = InStr(1, s, Tgt, vbTextCompare)
If nstart Then nstart = nstart + Len(Tgt)
nend = InStr(nstart, s, vbCrLf)
If nend < nstart + 2 Then nend = nstart + 9
If nend > nstart + 15 Then nend = nstart + 9
bl = Mid$(s, nstart, nend - nstart)

'Populate table
sql = "INSERT INTO tbl_XpLibnm (Dt, Acct, Acct_Nm, Acct_Bl,Cur_Lib)
" & _
"SELECT '" & Now & "' , '" & Name & "','" & _
1234 & "', '" & bl & "','" & lib & "'"
Set dbconn = CurrentProject.Connection
dbconn.Execute (sql)
' Close the internet explorer application and do cleanup
Set ie = Nothing
Set ipf = Nothing
Set lo = Nothing

End Function

Another peculiar occurance that seems to be related is that I am unable to
save the module and when attempted I recieve the error:
The save operation failed.
I have checked my reference libraries and have compared between a backed up
(working) copy of the db and there is no libref differences. I am utterly
bewildered by this error. Any thoughts?
 
W

WilliamAstarita

Well, the first thing I see wrong is that you have option explicit on
but you did not Dim the variables ie, S, nstart, nend, bl, SQL, ipf, lo
and lib anywhere that I can tell, it might be a global variable
somewhere else I can't see although I suspect the lib is a bound
control.

Also, using SQL as a variable name is bad practice as it is considered
a reserved keyword in access and probably many data enable references.

Test this by commenting out the Option Explicit line. If that works
great, but I would still use option explict and dim all variable and
change SQL to something like strSQL or SQLSource.

BTW the easiest way to figure these things out when they won't compile
is comment out all the lines and uncomment them one by one.

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top