Home Posts Topics Members FAQ
andigirlsc
1
I found some VBA code posted by ADezii on this site that will generate a list of users who are currently logged into my database. I pasted this code into the VBA window of a new blank form, following the instructions from the developer. The problem is I am getting a compile error whenever I run the code. I am using the Front End of an Access 2010 database. I also have access to the Back End as I have developed the DB myself. The code is listed as Private Function GenerateUserList() and is called from the Open Event in the form and is set to refresh every ten seconds.
What I have tried:
I tried pasting this code into a module and calling it in the form, but I the same line of code triggers an error. I researched and found similar posts, but not one that showed the same error I received. Any help is greatly appreciated!
Error Message:
Runtime error 3251. Object or provider is not capable of performing requested operation.
Code That Triggers Error:
Set rst = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaID:=conUsers)
Original VBA Code:
The code that triggers the error when I compile is in blue, bold print.
Code:
Expand|Select|Wrap|Line Numbers
- PrivateFunctionGenerateUserList()
- 'TheUserListSchemainformationrequiresthismagicnumber.Foranyone
- 'whomaybeinterested,thisnumberiscalledaGUIDorGloballyUnique
- 'Identifier-sorryfordigressing
- ConstconUsers="{947bb102-5d43-11d1-bdbf-00c04fb92675}"
- DimcnnAsADODB.Connection,fldAsADODB.Field,strUserAsString
- DimrstAsADODB.Recordset,intUserAsInteger,varValueAsVariant
- Setcnn=CurrentProject.Connection
- Setrst=cnn.OpenSchema(Schema:=adSchemaProviderSpecific,SchemaID:=conUsers)
- 'SetListBoxHeading
- strUser="Computer;UserName;Connected?;Suspect?"
- Withrst'fillsRecordset(rst)withUserListdata
- DoUntil.EOF
- intUser=intUser+1
- ForEachfldIn.Fields
- varValue=fld.Value
- 'SomeofthereturnvaluesareNull-TerminatedStrings,if
- 'sostripthemoff
- IfInStr(varValue,vbNullChar)>0Then
- varValue=Left(varValue,InStr(varValue,vbNullChar)-1)
- EndIf
- strUser=strUser&";"&varValue
- Next
- .MoveNext
- Loop
- EndWith
- Me!txtTotalNumOfUsers=intUser'Total#ofUsers
- 'SetupListBoxParameters
- Me!lstUsers.ColumnCount=4
- Me!lstUsers.RowSourceType="ValueList"
- Me!lstUsers.ColumnHeads=False
- lstUsers.RowSource=strUser'populatetheListBox
- 'Routinecleanupchores
- Setfld=Nothing
- Setrst=Nothing
- Setcnn=Nothing
- EndFunction
- PrivateSubForm_Open(CancelAsInteger)
- CallGenerateUserList
- EndSub
- PrivateSubForm_Timer()
- CallGenerateUserList
- EndSub
Dec 22 '14 #1
Subscribe Post Reply
2 3566
twinnyfo 3,653 Expert Mod 2GB
andigirlsc,
I use a slightly different version of this code:
Expand|Select|Wrap|Line Numbers
- OptionCompareDatabase
- OptionExplicit
- 'SetsomeConstantsandPublicVariables
- PrivateConstdbLockFileAsString="\\NetworkLocation\NetworkFolder\DatabaseName.laccdb"
- PrivateSubCurrentUsers()
- OnErrorGoToEH
- DimstrCurrentUsersAsString
- DimstrUserStringAsString
- DimintFileNumberAsInteger
- DimLineofTextAsString
- DimintPointerAsInteger
- intFileNumber=FreeFile
- IffIsFileDir(dbLockFile)Then
- OpendbLockFileForInputAs#intFileNumber
- Me.txtLockFileContents=""
- strCurrentUsers=""
- strUserString=""
- DoWhileNotEOF(intFileNumber)
- 'Readeachlineofthetextfileintoasinglestringvariable.
- LineInput#intFileNumber,LineofText
- WhileLen(LineofText)>0AndLen(LineofText)>=62
- intPointer=1
- DoWhileMid(LineofText,intPointer,1)<>""
- intPointer=intPointer+1
- Loop
- strUserString=Left(LineofText,intPointer-1)
- strCurrentUsers=IIf(Len(strCurrentUsers)=0,strUserString,_
- strCurrentUsers&vbCrLf&strUserString)
- LineofText=Right(LineofText,Nz(Len(LineofText)-62,0))
- Wend
- Loop
- Close#intFileNumber
- Me.txtLockFileContents=strCurrentUsers
- Else
- Me.txtLockFileContents="NoCurrentUsers"
- EndIf
- ExitSub
- EH:
- MsgBox"TherewasanerrorfindingallCurrentUsers."&_
- "PleasecontactyourDatabaseAdministrator.",vbCritical,"Error!"
- ExitSub
- EndSub
- PrivateFunctionfIsFileDir(strPathAsString,OptionallngTypeAsLong)AsInteger
- OnErrorResumeNext
- 'Checktoseeiffileexists
- fIsFileDir=Len(Dir(strPath,lngType))>0
- EndFunction
This will return the Computer Name of the user that is logged into the DB. With another table containing Computer Names and Users, you can easily find the person who is logged in.
Hope this hepps!
Feb 25 '15 #2
reply
sunnyk2057 1
Hi I am facing the same problem . Can you please help me out
Thanks
@twinnyfo I tried the code shared by you but its not returning anything
Expand|Select|Wrap|Line Numbers
- SubCurrentUsers()
- DimstrCurrentUsersAsString
- DimstrUserStringAsString
- DimintFileNumberAsInteger
- DimLineofTextAsString
- DimintPointerAsInteger
- DimdbLockFileAsString
- intFileNumber=FreeFile
- dbLockFile=CurrentProject.Path&"\"&CurrentDb.Name
- OpendbLockFileForInputAs#intFileNumber
- strCurrentUsers=""
- strUserString=""
- DoWhileNotEOF(intFileNumber)
- 'Readeachlineofthetextfileintoasinglestringvariable.
- LineInput#intFileNumber,LineofText
- WhileLen(LineofText)>0AndLen(LineofText)>=62
- intPointer=1
- DoWhileMid(LineofText,intPointer,1)<>""
- intPointer=intPointer+1
- Loop
- strUserString=Left(LineofText,intPointer-1)
- strCurrentUsers=IIf(Len(strCurrentUsers)=0,strUserString,_
- strCurrentUsers&vbCrLf&strUserString)
- LineofText=Right(LineofText,Nz(Len(LineofText)-62,0))
- Wend
- Loop
- Close#intFileNumber
- MsgBoxstrCurrentUsers
- EndSub
code i am trying to use
Apr 2 '15 #3
reply
Sign in to post your reply or Sign up for a free account.
Similar topics
6 Runtime Error by: Bill Patel |last post by: I am getting Runtime error on line 50. Please Help. Thank You Bill 1 <%@ Page Language="VB" %> 2 <%@ import Namespace="System.Data" %> 3 <%@ import Namespace="System.Data.SqlClient"... ASP.NET |
4 getting Runtime error instead of custom errors by: Pat |last post by: In my Web.config i have :- <customErrors mode="On" defaultRedirect="genericerror.htm"> <error statusCode="404" redirect="pagenotfound.aspx"/> </customErrors to get page not found error but... ASP.NET |
1 ADO runtime error 3251 by: ydprasad |last post by: I am trying to convert the code that was written in VB using DAO to ADO. But when i tried to do following getting an error '3251'. *************code************************** Dim cn As New... Visual Basic 4 / 5 / 6 |
6 Runtime Error 3251 Updating not allowed by: akoymakoy |last post by: Run time error 3251 Current Recordset does not support updating, this may be a limitation of the provider, or of the selected Locktype This is my simple program that will split the entries that... Visual Basic 4 / 5 / 6 |
7 Runtime error 3021- Either BOF or EOF is reached , unable to resolve this by: ruvi |last post by: I am getting runtime error 3021 - Either EOF or BOF is true or the current record has been deleted..... I have 2 combo boxes in a form- One for the client and the other for the project. When the... Visual Basic 4 / 5 / 6 |
1 Why am I getting Runtime error 3010? by: Lauren Dobson |last post by: This database was working days ago, outputting a vocabulary list into a word document. Any idea why I'm getting runtime error 3010? I just switched from Windows XP to Windows 7 but I'm still using... Microsoft Access / VBA |
1 i m getting runtime error ,i can,t understand ,please check it out by: creation |last post by: $b= 1; while($b) { $a = <>; if($a eq 42) break; else { print $a; } Perl |
1 getting runtime error 52 bas file name or number by: mishika |last post by: Q: getting runtime error 52 bas file name or number D:Public Function gf_ChkMkDir(iDirPath As String, iDirName As String) As Boolean Dim MyPath As String gf_ChkMkDir = False MyPath =... Microsoft Access / VBA |
8 Dcount getting runtime error '2471' by: Vasago |last post by: Bookings ID is number ID is autonumber Error says: Run-Time error '2471': The expression you entered as a query parameter produced this error: '' If DCount("", "Access Click log", " = " &... Microsoft Access / VBA |
Migrating Website to Cloud - Emmanuel Katto by: emmanuelkatto |last post by: Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel General |
1 Looking to do Android software development, any suggestions? Is flutter better? by: nemocccc |last post by: hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions? General |
How to build RAID in BIOS? by: Hystou |last post by: There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2... Computer Hardware |
Changing the language in Windows 10 by: Hystou |last post by: Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can... Windows Server |
Maximizing Business Potential: The Nexus of Website Design and Digital Marketing by: jinu1996 |last post by: In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven... Online Marketing |
The easy way to turn off automatic updates for Windows 10/11 by: Hystou |last post by: Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows... Windows Server |
Discussion: How does Zigbee compare with other wireless protocols in smart home applications? by: tracyyun |last post by: Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each... General |
AI Job Threat for Devs by: agi2029 |last post by: Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,... Career Advice |
Couldnt get equations in html when convert word .docx file to html file in C#. by: conductexam |last post by: I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and... C# / C Sharp |
By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.
To disable or enable advertisem*nts and analytics tracking please visit the page.