If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
“Invalid procedure call or argument”
When I open my Access 2003 database, I receive an immediate error: “Invalid
procedure call or argument”. The problem appears to be the code regarding the Open_Reporter (see code below). I have a module named “Login Code” with the code as shown below. I have checked to make sure that all the forms exist, that there are no missing references etc. but just can’t figure out what the problem is. If someone could give me some idea where to start it would be extremely helpful. Thanks in advance. Function ObjectExists(ObjType As Integer, ObjName As String) As Boolean 'Purpose: Determines whether or not a given object exists in database 'Example: If ObjectExists(acTable, "tblOrders") then ... On Error Resume Next Dim db As Database Dim strTemp As String, strContainer As String Set db = CurrentDb() Select Case ObjType Case acTable strTemp = db.TableDefs(ObjName).Name Case acQuery strTemp = db.QueryDefs(ObjName).Name Case acMacro, acModule, acForm, acReport Select Case ObjType Case acMacro strContainer = "Scripts" Case acModule strContainer = "Modules" Case acForm strContainer = "Forms" Case acReport strContainer = "Reports" End Select strTemp = db.Containers(strContainer).Documents(ObjName).Nam e End Select ObjectExists = (Err.Number = 0) End Function __________________________________________________ ________ Function SQL_Link_ok() As Boolean SQL_Link_ok = False On Error GoTo ERROR If Not ObjectExists(acQuery, "qrySQLTables") Then Exit Function If IsNull(DLookup("Name", "qrySQLTables", "'ProfileFields'")) Then Exit Function Else SQL_Link_ok = True End If ERROR: End Function __________________________________________________ _____ Function Open_Reporter() If SQL_Link_ok Then DoCmd.OpenForm "frmMainMenu", acNormal, "", "", , acNormal DoCmd.Maximize DoCmd.Close acForm, "frmOpen" Else DoCmd.OpenForm "frmConnect", acNormal, "", "", , acNormal End If Open_Reporter = 0 End Function -- S |
#2
|
|||
|
|||
“Invalid procedure call or argument”
Why not set a breakpoint and see exactly what statement is causing the error?
-Dorian "Sharon" wrote: When I open my Access 2003 database, I receive an immediate error: “Invalid procedure call or argument”. The problem appears to be the code regarding the Open_Reporter (see code below). I have a module named “Login Code” with the code as shown below. I have checked to make sure that all the forms exist, that there are no missing references etc. but just can’t figure out what the problem is. If someone could give me some idea where to start it would be extremely helpful. Thanks in advance. Function ObjectExists(ObjType As Integer, ObjName As String) As Boolean 'Purpose: Determines whether or not a given object exists in database 'Example: If ObjectExists(acTable, "tblOrders") then ... On Error Resume Next Dim db As Database Dim strTemp As String, strContainer As String Set db = CurrentDb() Select Case ObjType Case acTable strTemp = db.TableDefs(ObjName).Name Case acQuery strTemp = db.QueryDefs(ObjName).Name Case acMacro, acModule, acForm, acReport Select Case ObjType Case acMacro strContainer = "Scripts" Case acModule strContainer = "Modules" Case acForm strContainer = "Forms" Case acReport strContainer = "Reports" End Select strTemp = db.Containers(strContainer).Documents(ObjName).Nam e End Select ObjectExists = (Err.Number = 0) End Function __________________________________________________ ________ Function SQL_Link_ok() As Boolean SQL_Link_ok = False On Error GoTo ERROR If Not ObjectExists(acQuery, "qrySQLTables") Then Exit Function If IsNull(DLookup("Name", "qrySQLTables", "'ProfileFields'")) Then Exit Function Else SQL_Link_ok = True End If ERROR: End Function __________________________________________________ _____ Function Open_Reporter() If SQL_Link_ok Then DoCmd.OpenForm "frmMainMenu", acNormal, "", "", , acNormal DoCmd.Maximize DoCmd.Close acForm, "frmOpen" Else DoCmd.OpenForm "frmConnect", acNormal, "", "", , acNormal End If Open_Reporter = 0 End Function -- S |
#3
|
|||
|
|||
"Invalid procedure call or argument"
Put in some actual error handling code. Try MZ Tools, its free and
very useful. On Error Resume next won't help much. In Tools Options you might set the choice to break on all errors... HTH -- -Larry- -- "Sharon" wrote in message ... When I open my Access 2003 database, I receive an immediate error: "Invalid procedure call or argument". The problem appears to be the code regarding the Open_Reporter (see code below). I have a module named "Login Code" with the code as shown below. I have checked to make sure that all the forms exist, that there are no missing references etc. but just can't figure out what the problem is. If someone could give me some idea where to start it would be extremely helpful. Thanks in advance. Function ObjectExists(ObjType As Integer, ObjName As String) As Boolean 'Purpose: Determines whether or not a given object exists in database 'Example: If ObjectExists(acTable, "tblOrders") then ... On Error Resume Next Dim db As Database Dim strTemp As String, strContainer As String Set db = CurrentDb() Select Case ObjType Case acTable strTemp = db.TableDefs(ObjName).Name Case acQuery strTemp = db.QueryDefs(ObjName).Name Case acMacro, acModule, acForm, acReport Select Case ObjType Case acMacro strContainer = "Scripts" Case acModule strContainer = "Modules" Case acForm strContainer = "Forms" Case acReport strContainer = "Reports" End Select strTemp = db.Containers(strContainer).Documents(ObjName).Nam e End Select ObjectExists = (Err.Number = 0) End Function __________________________________________________ ________ Function SQL_Link_ok() As Boolean SQL_Link_ok = False On Error GoTo ERROR If Not ObjectExists(acQuery, "qrySQLTables") Then Exit Function If IsNull(DLookup("Name", "qrySQLTables", "'ProfileFields'")) Then Exit Function Else SQL_Link_ok = True End If ERROR: End Function __________________________________________________ _____ Function Open_Reporter() If SQL_Link_ok Then DoCmd.OpenForm "frmMainMenu", acNormal, "", "", , acNormal DoCmd.Maximize DoCmd.Close acForm, "frmOpen" Else DoCmd.OpenForm "frmConnect", acNormal, "", "", , acNormal End If Open_Reporter = 0 End Function -- S |
#4
|
|||
|
|||
“Invalid procedure call or argument”
Not really familiar with all of the possibilities of debugging, but I have
tried to compile and toggle the breakpoint and it highlights the very first line of the Open_Reporter ()" code. -- S "mscertified" wrote: Why not set a breakpoint and see exactly what statement is causing the error? -Dorian "Sharon" wrote: When I open my Access 2003 database, I receive an immediate error: “Invalid procedure call or argument”. The problem appears to be the code regarding the Open_Reporter (see code below). I have a module named “Login Code” with the code as shown below. I have checked to make sure that all the forms exist, that there are no missing references etc. but just can’t figure out what the problem is. If someone could give me some idea where to start it would be extremely helpful. Thanks in advance. Function ObjectExists(ObjType As Integer, ObjName As String) As Boolean 'Purpose: Determines whether or not a given object exists in database 'Example: If ObjectExists(acTable, "tblOrders") then ... On Error Resume Next Dim db As Database Dim strTemp As String, strContainer As String Set db = CurrentDb() Select Case ObjType Case acTable strTemp = db.TableDefs(ObjName).Name Case acQuery strTemp = db.QueryDefs(ObjName).Name Case acMacro, acModule, acForm, acReport Select Case ObjType Case acMacro strContainer = "Scripts" Case acModule strContainer = "Modules" Case acForm strContainer = "Forms" Case acReport strContainer = "Reports" End Select strTemp = db.Containers(strContainer).Documents(ObjName).Nam e End Select ObjectExists = (Err.Number = 0) End Function __________________________________________________ ________ Function SQL_Link_ok() As Boolean SQL_Link_ok = False On Error GoTo ERROR If Not ObjectExists(acQuery, "qrySQLTables") Then Exit Function If IsNull(DLookup("Name", "qrySQLTables", "'ProfileFields'")) Then Exit Function Else SQL_Link_ok = True End If ERROR: End Function __________________________________________________ _____ Function Open_Reporter() If SQL_Link_ok Then DoCmd.OpenForm "frmMainMenu", acNormal, "", "", , acNormal DoCmd.Maximize DoCmd.Close acForm, "frmOpen" Else DoCmd.OpenForm "frmConnect", acNormal, "", "", , acNormal End If Open_Reporter = 0 End Function -- S |
#5
|
|||
|
|||
“Invalid procedure call or argument”
Hi Sharon,
I cleaned up a bit of your code. See if this works. I found several error handling problems. Your OpenReporter function was assigned a value that wasn't returned (forgot to put "As Integer" at the end of the header since it always returns zero. Here is my version: ----------------------- Option Compare Database Option Explicit Public Function ObjectExists(ObjType As Integer, ObjName As String) As Boolean On Error GoTo ErrFunction Dim db As Database Dim strTemp As String, strContainer As String Set db = CurrentDb() Select Case ObjType Case acTable strTemp = db.TableDefs(ObjName).Name Case acQuery strTemp = db.QueryDefs(ObjName).Name Case acMacro, acModule, acForm, acReport Select Case ObjType Case acMacro strContainer = "Scripts" Case acModule strContainer = "Modules" Case acForm strContainer = "Forms" Case acReport strContainer = "Reports" End Select strTemp = db.Containers(strContainer).Documents(ObjName).Nam e End Select ObjectExists = (Err.Number = 0) ExitFunction: Exit Function ErrFunction: MsgBox Err.Description Resume ExitFunction End Function Public Function SQL_Link_ok() As Boolean On Error GoTo ErrFunction If Not ObjectExists(acQuery, "qrySQLTables") Then SQL_Link_ok = False ElseIf IsNull(DLookup("Name", "qrySQLTables", "'ProfileFields'")) Then SQL_Link_ok = False Else SQL_Link_ok = True End If ExitFunction: Exit Function ErrFunction: MsgBox Err.Description Resume ExitFunction End Function Function Open_Reporter() As Integer On Error GoTo ErrFunction If SQL_Link_ok = True Then DoCmd.OpenForm "frmMainMenu", acNormal, "", "", , acNormal DoCmd.Maximize DoCmd.Close acForm, "frmOpen" Else DoCmd.OpenForm "frmConnect", acNormal, "", "", , acNormal End If Open_Reporter = 0 ExitFunction: Exit Function ErrFunction: MsgBox Err.Description Resume ExitFunction End Function ----------------------- "Sharon" wrote: When I open my Access 2003 database, I receive an immediate error: “Invalid procedure call or argument”. The problem appears to be the code regarding the Open_Reporter (see code below). I have a module named “Login Code” with the code as shown below. I have checked to make sure that all the forms exist, that there are no missing references etc. but just can’t figure out what the problem is. If someone could give me some idea where to start it would be extremely helpful. Thanks in advance. Function ObjectExists(ObjType As Integer, ObjName As String) As Boolean 'Purpose: Determines whether or not a given object exists in database 'Example: If ObjectExists(acTable, "tblOrders") then ... On Error Resume Next Dim db As Database Dim strTemp As String, strContainer As String Set db = CurrentDb() Select Case ObjType Case acTable strTemp = db.TableDefs(ObjName).Name Case acQuery strTemp = db.QueryDefs(ObjName).Name Case acMacro, acModule, acForm, acReport Select Case ObjType Case acMacro strContainer = "Scripts" Case acModule strContainer = "Modules" Case acForm strContainer = "Forms" Case acReport strContainer = "Reports" End Select strTemp = db.Containers(strContainer).Documents(ObjName).Nam e End Select ObjectExists = (Err.Number = 0) End Function __________________________________________________ ________ Function SQL_Link_ok() As Boolean SQL_Link_ok = False On Error GoTo ERROR If Not ObjectExists(acQuery, "qrySQLTables") Then Exit Function If IsNull(DLookup("Name", "qrySQLTables", "'ProfileFields'")) Then Exit Function Else SQL_Link_ok = True End If ERROR: End Function __________________________________________________ _____ Function Open_Reporter() If SQL_Link_ok Then DoCmd.OpenForm "frmMainMenu", acNormal, "", "", , acNormal DoCmd.Maximize DoCmd.Close acForm, "frmOpen" Else DoCmd.OpenForm "frmConnect", acNormal, "", "", , acNormal End If Open_Reporter = 0 End Function -- S |
#6
|
|||
|
|||
“Invalid procedure call or argument”
Small error in my version:
In the ObjectExists function put back: On Error Resume Next at the beginning See ya! "Sharon" wrote: When I open my Access 2003 database, I receive an immediate error: “Invalid procedure call or argument”. The problem appears to be the code regarding the Open_Reporter (see code below). I have a module named “Login Code” with the code as shown below. I have checked to make sure that all the forms exist, that there are no missing references etc. but just can’t figure out what the problem is. If someone could give me some idea where to start it would be extremely helpful. Thanks in advance. Function ObjectExists(ObjType As Integer, ObjName As String) As Boolean 'Purpose: Determines whether or not a given object exists in database 'Example: If ObjectExists(acTable, "tblOrders") then ... On Error Resume Next Dim db As Database Dim strTemp As String, strContainer As String Set db = CurrentDb() Select Case ObjType Case acTable strTemp = db.TableDefs(ObjName).Name Case acQuery strTemp = db.QueryDefs(ObjName).Name Case acMacro, acModule, acForm, acReport Select Case ObjType Case acMacro strContainer = "Scripts" Case acModule strContainer = "Modules" Case acForm strContainer = "Forms" Case acReport strContainer = "Reports" End Select strTemp = db.Containers(strContainer).Documents(ObjName).Nam e End Select ObjectExists = (Err.Number = 0) End Function __________________________________________________ ________ Function SQL_Link_ok() As Boolean SQL_Link_ok = False On Error GoTo ERROR If Not ObjectExists(acQuery, "qrySQLTables") Then Exit Function If IsNull(DLookup("Name", "qrySQLTables", "'ProfileFields'")) Then Exit Function Else SQL_Link_ok = True End If ERROR: End Function __________________________________________________ _____ Function Open_Reporter() If SQL_Link_ok Then DoCmd.OpenForm "frmMainMenu", acNormal, "", "", , acNormal DoCmd.Maximize DoCmd.Close acForm, "frmOpen" Else DoCmd.OpenForm "frmConnect", acNormal, "", "", , acNormal End If Open_Reporter = 0 End Function -- S |
Thread Tools | |
Display Modes | |
|
|