Solved

Error counting number of users logged into the same database

Posted on 2011-03-03
8
246 Views
Last Modified: 2012-05-11
I have a function that counts the number of users logged into and Access 2003 front-end running on a server.  This code (originally supplied via an EE post) has been working for years, but this morning I went onto a site and got an Error number 13 (type mismatch) error.

I haven't changed anything on this code (that I am aware of), but am wondering why it might not work.

Any suggestions would be massively appreciated.
Public Function CountUsers() As Long

    Const USERROSTER_SCHEMA As String = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"  ' User roster schema GUID
    Dim rstUserRoster As ADODB.Recordset  ' User roster recordset 
    Set rstUserRoster = CurrentProject.Connection.OpenSchema(adSchemaProviderSpecific, , USERROSTER_SCHEMA)

    Do Until rstUserRoster.EOF
        CountUsers = CountUsers + 1  ' Can't use RecordCount!
        rstUserRoster.MoveNext
    Loop

end function

Open in new window

0
Comment
Question by:Andy Brown
  • 5
  • 3
8 Comments
 

Author Comment

by:Andy Brown
ID: 35025882
Ah should have said, the error is caused when the:

Set rstUserRoster = CurrentProject.Connection.OpenSchema(adSchemaProviderSpecific, , USERROSTER_SCHEMA)

is run.  I do have some error correction on this function (I just removed it to make it easier to read).
0
 
LVL 84
ID: 35026978
My first thought would be a bad/corrupt installation of MDAC. You can determine this by running Component Checker (http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8f0a8df6-4a21-4b43-bf53-14332ef092c9). This checks your installation of MDAC (of which ADO is a component) and tells you if there are issues.
0
 

Author Comment

by:Andy Brown
ID: 35028098
Will do, the only other thing that I can think of is that I installed Win 7 SP1 over the weekend on my machine, compiled the front-end and and then took over the MDE file with me this morning.  Although I cannot see how this would have affected the code, it was the only thing that sprang to mind.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 35033052
< I installed Win 7 SP1 over the weekend on my machine>

That could be your trouble. SP1 caused some catastrophic issues with MDAC/ADO:

http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/3a4ce946-effa-4f77-98a6-34f11c6b5a13

Basically, Microsoft's answer is "use late binding", i.e.:


 Set rstUserRoster = CreateObject("ADODB.Recordset")
 Set rstUserRoser = CurrentProject.Connection.OpenSchema(adSchemaProviderSpecific, , USERROSTER_SCHEMA)

I"m not sure that would work either.

You can also uninstall the Service Pack, or do one of the other fixes mentioned.

0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Andy Brown
ID: 35034763
Thanks LSM,

Just before I start playing.  Are you aware of any other (potentially safer) ways to determine the number of users logged in (I'm not using an .mdw file)?

0
 
LVL 84
ID: 35035201
No. The Schema method is the most reliable method of doing this.
0
 

Author Closing Comment

by:Andy Brown
ID: 35035397
Thanks LSM - I've updated the code, and will go on-site, on monday to give it a blast.

Thanks as always - have a great weekend.
0
 

Author Comment

by:Andy Brown
ID: 35067988
Just to let you know - the late binding worked fine - thanks again.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now