A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

“Invalid procedure call or argument”



 
 
Thread Tools Display Modes
  #1  
Old March 19th, 2008, 03:04 PM posted to microsoft.public.access.tablesdbdesign
Sharon
external usenet poster
 
Posts: 491
Default “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  
Old March 19th, 2008, 03:37 PM posted to microsoft.public.access.tablesdbdesign
mscertified
external usenet poster
 
Posts: 835
Default “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  
Old March 19th, 2008, 04:27 PM posted to microsoft.public.access.tablesdbdesign
Larry Daugherty
external usenet poster
 
Posts: 1,012
Default "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  
Old March 19th, 2008, 06:16 PM posted to microsoft.public.access.tablesdbdesign
Sharon
external usenet poster
 
Posts: 491
Default “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  
Old March 25th, 2008, 07:21 PM posted to microsoft.public.access.tablesdbdesign
Ray C
external usenet poster
 
Posts: 215
Default “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  
Old March 25th, 2008, 07:25 PM posted to microsoft.public.access.tablesdbdesign
Ray C
external usenet poster
 
Posts: 215
Default “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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.