Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error '5' Invalid procedure call or argument 1

Status
Not open for further replies.

jjlogan

Programmer
Jan 11, 2002
178
US
I suddenly started getting this error message after my database has been used for years. Each year we copy the last mdb file and load the current year's accounting data. The problem is occuring in my user interface form when user clicks a button to run a history report for the natural class that is being worked on in current form. This has always worked. The code behind the history button starts out with dim statements, then three Input boxes, then an evaluation of the user's response from Input box (all very usual): here it is:
Dim strNCDefault As String, strYearDefault As String, strRespDefault As String
Dim NCResponse As String
Dim YearResponse As String
Dim RespResponse As String
Dim strYear As String 'holds final form of what user selected
Dim adstrYear As String 'hold ADO which could have ADO specific wildcards
Dim strResp As String 'holds final form of what user selected
Dim adstrResp As String 'hold ADO where wildcards could be used - different from Jet 4.0
Dim strWhere As String
Dim adstrWhere As String 'hold ADO where clause which differs from Jet 4.0 SQL
Dim strOpenArgs As String 'passed to Open Report method to display in report header
Dim strSQL As String
Dim rs As ADODB.Recordset

' Set defaults for NC, year, and responsible organization. Resp can now be Corp or XYZ orgn.
strNCDefault = Me.NC
strYearDefault = "All years"
strRespDefault = "Corp"

' Ask user for NC, Year, and Responsible organization
NCResponse = InputBox("Specify NC", "Run NC History", strNCDefault)
YearResponse = InputBox("Specify year (e.g. 2007)" & vbCrLf & "or Enter for All Years", "Run NC History", strYearDefault)
RespResponse = InputBox("Specify RESP (Corp, B-XYZ, B-ABC, B-DEF, B (for all 'B' Resp's), or ALL)", "Run NC History", strRespDefault)

If YearResponse = strYearDefault Then
strYear = "*"
adstrYear = "%"
strOpenArgs = "All " & NCResponse
Else
strYear = YearResponse
adstrYear = YearResponse
strOpenArgs = YearResponse & NCResponse
End If

The error pops up near the end on line "If YearResponse = strYearDefault Then".
I checked the values in YearResponse and in strYearDefault by hovering the mouse, and there are exactly the same.
Thanks for any assist you can think of.
Oh, I am using Windows XP, Access 2007 but file is format 2003, VBA References are Visual Basic for Apps, Microsoft Access 12.0 Obj Library, OLE Automation, MS DAO 3.6 Obj Lib, and MS Active Data Objects 2.8 Lib.
Jeff
 
I cannot see anything obvious. If it was me, I would worry about possible corruption. I would create a new clean database. Then import all the objects into it. Then add all of your references back in. Compact and repair and compile.
 
OK and thanks MajP. Will give it a go. Clean db.
Jeff
 
Post back if that does not help. The error message does not seem to match anything associated to the line in question, so kind of guessing it is some kind of corruption or memory issue.
 
MajP - Yes finally. Your solution worked. Created clean db, imported objects in (that took a while but allowed me to clean house), then ran the automation and no Error '5'.
Thanks,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top