Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

"Err object" will not compile

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eddie's Bakery and Cafe' - 08 Mar 2005 23:53 GMT
Hi, I am trying to use the Err object, but every time I compile my VBA
application I get a compile error, "Invalid Qualifier"

If you have any suggestions, I would greatly appreciate them.

Thanks for your help
Signature

Eddie Eytchison

Dirk Goldgar - 09 Mar 2005 00:00 GMT
> Hi, I am trying to use the Err object, but every time I compile my VBA
> application I get a compile error, "Invalid Qualifier"
>
> If you have any suggestions, I would greatly appreciate them.
>
>  Thanks for your help

How about posting your code so we can see what might be wrong?

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Eddie's Bakery and Cafe' - 09 Mar 2005 00:31 GMT
Hi Dirk,  I get the error at Err.Source, Thanks for your help
--

 If Err <> 0 Then
   MsgBox "clsDBManager[read_DBTable]: Error, in trying to open database"
   Debug.Print "clsDBManager[read_DBTable]: Error, in trying to open
database"
   MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If

> > Hi, I am trying to use the Err object, but every time I compile my VBA
> > application I get a compile error, "Invalid Qualifier"
[quoted text clipped - 4 lines]
>
> How about posting your code so we can see what might be wrong?
Dirk Goldgar - 09 Mar 2005 00:57 GMT
> Hi Dirk,  I get the error at Err.Source, Thanks for your help
>
[quoted text clipped - 4 lines]
>     MsgBox Err.Source & "-->" & Err.Description, , "Error"
>   End If

I don't see the problem.  Zoom out a bit.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Eddie's Bakery and Cafe' - 09 Mar 2005 01:39 GMT
Hi, Dirk, This is the subroutine where I seem to be spending all my time.  I
also get a run-time error when I switch between “Design View” and “Form
View”, the error is:

Run-Time Error …. “The database has been placed in a state by user ‘Admin’
on        machine … that prevents if from being opened or locked.”

I am opening a table and putting its data into collection objects that are
passed back to the caller.  In addition to the “Err.Source” error, the db
open error is occurring at line number 26 (conn.Open strConn).  Thanks for
all your help  

1)    Public Sub Read_DBTable (ByVal tblName as String, _
2)          ByVal dbName as String, _
3)          ByRef myContainer as Container)
4)        
4.1)    On Error GoTo ErrorHandler
4.2)
5)      Dim conn As ADODB.Connection
6)      Dim rs As ADODB.recordSet
7)      Dim tmpSQLstr As String
8)      Dim strConn As String
9)      Dim  NumOfRows as Integer
10)    
11)    tmpSQLstr = "SELECT "
12)        tmpSQLstr = tmpSQLstr + tblName & ".* "
13)        tmpSQLstr = tmpSQLstr + " FROM "
14)        tmpSQLstr = tmpSQLstr + tblName
15)        tmpSQLstr = tmpSQLstr + " WHERE "
16)        tmpSQLstr = tmpSQLstr + tblName
17)        tmpSQLstr = tmpSQLstr + ".ForeignKey = 2 "
18)        tmpSQLstr = tmpSQLstr + "ORDER BY "
19)        tmpSQLstr = tmpSQLstr + tblName
20)        tmpSQLstr = tmpSQLstr + ".Name;"
21)    
22)    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
23)            "Data Source=" & CurrentProject.Path & "\" & dbName & ";"
24)    
25)     Set conn = New ADODB.Connection
26)     conn.Open strConn
27)    
28)     Set rs = New ADODB.recordSet
29)     rs.Open tmpSQLstr, conn, adOpenKeyset, adLockOptimistic
30)    
31)     If rs.BOF And rs.EOF Then
32)       Exit Sub ‘ No Records were found
33)     End If
34)    
35)     NumOfRows = 1
36)      
37)     Do Until rs.EOF
38)         myContainer.Add (rs.Fields.Item(0).value), CStr(numOfRows)
39)         NumOfRows = numOfRows + 1
40)        rs.MoveNext
41)    Loop
42)      
43)     rs.Close
44)    conn.Close
45)    
46)     Set rs = Nothing
47)     Set conn = Nothing
48)     Exit Sub
49)    
50)   ErrorHandler:
51 )    
52 )   If Not rs Is Nothing Then
54)       If rs.State = adStateOpen Then rs.Close
55)    End If
56)    
57)    Set rs = Nothing
58)    
59)    If Not conn Is Nothing Then
60)       If conn.State = adStateOpen Then conn.Close
61)    End If
62)    
63)    Set conn = Nothing
64)    
65)    If Err <> 0 Then
66)      MsgBox "clsDBManager[read_DBTable]: Error, in trying to open
database"
67)      Debug.Print "clsDBManager[read_DBTable]: Error, in trying to open
database"
68)      MsgBox Err.Source & "-->" & Err.Description, , "Error"
69)    End If
70)  End Function

PS: Dirk, if you don’t already known, I am changing careers to become a
baker. Since you have been such a tremendous help, I would like to send you
some goodies from the bakery where I am training. If you give me you mailing
address I will be glad to send you some goodies.  My email address is
eytchison@hotmail.com

Thanks,  Eddie

> > Hi Dirk,  I get the error at Err.Source, Thanks for your help
> >
[quoted text clipped - 7 lines]
>
> I don't see the problem.  Zoom out a bit.
Dirk Goldgar - 09 Mar 2005 03:19 GMT
> Hi, Dirk, This is the subroutine where I seem to be spending all my
> time.  I also get a run-time error when I switch between "Design
[quoted text clipped - 82 lines]
> 69)    End If
> 70)  End Function

That code has some oddities that give me compile errors before even
getting to the problem you're posting about.  You can't have copied and
pasted it;  what did you change in transcription?  Line 32 gives me an
error because of the ` character you've used instead of a ' character,
but more importantly, you speak in your post of a collection object, but
you Dim myContainer as Container.  The only Container object I know
about is the DAO Container object, and that has no Add method and
wouldn't be what you wanted to use.

If I change "Container" to "Collection", and fix that ` character, the
code compiles for me without error.  So I think you'd better copy and
paste your actual code if I'm to have any chance at debugging it.

> PS: Dirk, if you don't already known, I am changing careers to become
> a baker. Since you have been such a tremendous help, I would like to
> send you some goodies from the bakery where I am training. If you
> give me you mailing address I will be glad to send you some goodies.

That's very thoughtful of you, and I'll take you up on the offer --
after we've solved this problem of yours.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Eddie's Bakery and Cafe' - 09 Mar 2005 03:41 GMT
Hi Dirk, Your are correct, I was trying to keep the code simple.  The
variable is a collection and not a container.

Here's the actual code that I have in my program:  

Public Function read_DBTable(ByVal tblName As String, _
                             ByRef PKeys As Collection, _
                             ByRef FKeys As Collection, _
                             ByRef RecipeNames As Collection, _
                             ByRef numOfRows As Integer) As errType
 On Error GoTo ErrorHandler
 
 Dim conn As ADODB.Connection
 Dim rs As ADODB.recordSet
 Dim tmpSQLstr As String
 Dim strConn As String

 Debug.Print ""
 Debug.Print "clsDBManager[read_DBTable]: Entry Point "
 
 read_DBTable = noError
 
 ' open the connection using the tmpSQLstr parameter
 tmpSQLstr = "SELECT "
   tmpSQLstr = tmpSQLstr + tblName & ".* "
 tmpSQLstr = tmpSQLstr + " FROM "
   tmpSQLstr = tmpSQLstr + tblName
   tmpSQLstr = tmpSQLstr + " WHERE "
   tmpSQLstr = tmpSQLstr + tblName
   tmpSQLstr = tmpSQLstr + ".ForeignKey = 2 "
   tmpSQLstr = tmpSQLstr + "ORDER BY "
   tmpSQLstr = tmpSQLstr + tblName
   tmpSQLstr = tmpSQLstr + ".Name;"
   
 strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=" & CurrentProject.Path & _
           "\" & parm.dbName & ";"
 
 ' open the connection us
 Set conn = New ADODB.Connection
 conn.Open strConn
 
 ' open database table
 Set rs = New ADODB.recordSet
 rs.Open tmpSQLstr, conn, adOpenKeyset, adLockOptimistic
 
 Debug.Print "   --- Opening database """ & parm.dbName & """ and table """
& tblName & """"
 
 If rs.BOF And rs.EOF Then
   MsgBox "clsDBManager[read_DBTable]: ERROR, did not find any records in
database table """ & tblName & """"
   Debug.Print "clsDBManager[read_DBTable]: ERROR, did not find any records
in database table """ & tblName & """"
   read_DBTable = errOccured
   Exit Function
 End If
 
 numOfRows = 1
 
 Do Until rs.EOF
   ' we don't want to store blank data in the collection; therefore, if we
   '   encounter a blank, we need to skip the record
   If IsNull(rs.Fields.Item(2)) Then
     read_DBTable = errOccured
     Debug.Print "clsDBManager[read_DBTable]: Error in table, check table
values [" & _
                                               rs.Fields.Item(0) & ":" & _
                                               rs.Fields.Item(1) & ":" & _
                                               rs.Fields.Item(2) & """]"
   Else
     PKeys.Add (rs.Fields.Item(0).value), CStr(numOfRows)
     FKeys.Add (rs.Fields.Item(1).value), CStr(numOfRows)
     RecipeNames.Add (rs.Fields.Item(2).value), CStr(numOfRows)

     Debug.Print "   --- Saving table data[" & numOfRows; "]: """ & _
                         rs.Fields.Item(0).value & ":" & _
                         rs.Fields.Item(1).value & ":" & _
                         rs.Fields.Item(2).value & """"

     numOfRows = numOfRows + 1
   End If

  ' move to the next row in the table
  rs.MoveNext
 Loop

' Add EOF Marker to last record in collection
 PKeys.Add 0, CStr(numOfRows)
 FKeys.Add 0, CStr(numOfRows)
 RecipeNames.Add "EOF", CStr(numOfRows)

' set the number of rows to include all the table data except the "EOF" record
' the "EOF" marker is there for safty reasons
 numOfRows = numOfRows - 1

' clean up
 rs.Close
 conn.Close

 Set rs = Nothing
 Set conn = Nothing

 Debug.Print "clsDBManager[read_DBTable]: Exit Point "
 Debug.Print ""
 
 Exit Function
 
ErrorHandler:
 read_DBTable = errOccured
 ' clean up
 If Not rs Is Nothing Then
     If rs.State = adStateOpen Then rs.Close
 End If
 
 Set rs = Nothing
   
 If Not conn Is Nothing Then
   If conn.State = adStateOpen Then conn.Close
 End If
 
 Set conn = Nothing
   
 If Err <> 0 Then
   MsgBox "clsDBManager[read_DBTable]: Error, in trying to open database"
   Debug.Print "clsDBManager[read_DBTable]: Error, in trying to open
database"
'    MsgBox Err.Source & "-->" & Err.Description, , "Error"
 End If
End Function

> > Hi, Dirk, This is the subroutine where I seem to be spending all my
> > time.  I also get a run-time error when I switch between "Design
[quoted text clipped - 103 lines]
> That's very thoughtful of you, and I'll take you up on the offer --
> after we've solved this problem of yours.
Dirk Goldgar - 09 Mar 2005 04:13 GMT
> Hi Dirk, Your are correct, I was trying to keep the code simple.  The
> variable is a collection and not a container.
>
> Here's the actual code that I have in my program:
[snip]

Ah, that helps a lot.  I still don't have an answer for you, but I can
say that after I worked around errors caused by the undefined words
"errType", "noError",  "errOccured", and "parm.dbname",  The module
compiled for me with no errors at all.

I wonder if you have possibly defined a variable, object, or type named
"Err" or "ErrObject", and that's confusing the compiler.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Eddie's Bakery and Cafe' - 09 Mar 2005 04:27 GMT
Hi Dirk, I defined separates classes that has the missing variables:  
 
Public Enum errType
 noError = 1
 errOccured = 0
End Enum

Private dbName_loc As String

Public Property Let dbName(ByVal value As String)
 dbName_loc = value
End Property
Public Property Get dbName() As String
 dbName = dbName_loc
End Property

Private Sub Class_Initialize()
  dbName_loc = "myDB"
End Sub

Thanks for your time, Eddie

> > Hi Dirk, Your are correct, I was trying to keep the code simple.  The
> > variable is a collection and not a container.
[quoted text clipped - 9 lines]
> I wonder if you have possibly defined a variable, object, or type named
> "Err" or "ErrObject", and that's confusing the compiler.
Dirk Goldgar - 09 Mar 2005 04:51 GMT
> Hi Dirk, I defined separates classes that has the missing variables:
>
[quoted text clipped - 31 lines]
>> I wonder if you have possibly defined a variable, object, or type
>> named "Err" or "ErrObject", and that's confusing the compiler.

That's fine but it still leaves me with a module that compiles without
error, so I can't reproduce your problem.  I have to guess it's caused
by something defined in other code that I haven't seen.

What happens if, while editing the function you posted, you click on the
name "Err" in the statement

   MsgBox Err.Source & "-->" & Err.Description, , "Error"

and then press Shift+F2?  Where does that take you?

Note:  I'm signing off for the night now.  If you can't see anything
helpful as a result of the above, then you may send me a cut-down copy
of your database, containing only the elements necessary to demonstrate
the problem, compacted and then zipped to less than 1MB in size
(preferably much smaller).  I'll have a look at it, time permitting.
You can send it to the address derived by removing NO SPAM from the
reply address of this message.  If you're using the web interface and it
won't show you the reply address, you can get my e-mail address from my
web site, which is listed below.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Eddie's Bakery and Cafe' - 09 Mar 2005 05:35 GMT
Hi Dirk,

Thanks for your help last night, one problem solved and one to go.  Your tip
worked; when I used the Shif/F2 key combo, it took me to a local constant
that defined Err as zero -- “Const Err = 0”.

Once I took it out, it solved my first problem. The statement:

 MsgBox Err.Source & "-->" & Err.Description, , "Error"

is now working 

I will keep working on the other problem. If I don’t have any luck, I will
try to isolate the problem in a small zip file. However, I really hope I
won’t have to trouble you with this level of detail.  I am wondering if there
is a patch that I am missing because I have been having the “Lock DB” problem
every since I started the project.  

Once again, thanks for all your assistance and patience,

Eddie

PS: Don’t forget to send me you address.

> > Hi Dirk, I defined separates classes that has the missing variables:
> >
[quoted text clipped - 52 lines]
> won't show you the reply address, you can get my e-mail address from my
> web site, which is listed below.
Dirk Goldgar - 09 Mar 2005 18:22 GMT
> Hi Dirk,
>
[quoted text clipped - 7 lines]
>
> is now working ?

Excellent!

> I will keep working on the other problem. If I don't have any luck, I
> will try to isolate the problem in a small zip file. However, I
> really hope I won't have to trouble you with this level of detail.  I
> am wondering if there is a patch that I am missing because I have
> been having the "Lock DB" problem every since I started the project.

I doubt that's it, but I haven't really looked at your posts on this
problem.

> Once again, thanks for all your assistance and patience

You're welcome.

> PS: Don't forget to send me you address.

Oh, goodie!  I'll send it off right away.  :-)

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Eddie's Bakery and Cafe' - 09 Mar 2005 19:43 GMT
Hi Dirk,  I just sent you a small zip file using the email address from your
web site. Let me know if you don't get it.

Thanks,  Eddie

> > Hi Dirk, I defined separates classes that has the missing variables:
> >
[quoted text clipped - 52 lines]
> won't show you the reply address, you can get my e-mail address from my
> web site, which is listed below.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.