Why Am I Getting Runtime Error 3251? - Microsoft Access (2024)

Home Posts Topics Members FAQ

andigirlsc

Why Am I Getting Runtime Error 3251? - Microsoft Access (1) 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

  1. PrivateFunctionGenerateUserList()
  2. 'TheUserListSchemainformationrequiresthismagicnumber.Foranyone
  3. 'whomaybeinterested,thisnumberiscalledaGUIDorGloballyUnique
  4. 'Identifier-sorryfordigressing
  5. ConstconUsers="{947bb102-5d43-11d1-bdbf-00c04fb92675}"
  6. DimcnnAsADODB.Connection,fldAsADODB.Field,strUserAsString
  7. DimrstAsADODB.Recordset,intUserAsInteger,varValueAsVariant
  8. Setcnn=CurrentProject.Connection
  9. Setrst=cnn.OpenSchema(Schema:=adSchemaProviderSpecific,SchemaID:=conUsers)
  10. 'SetListBoxHeading
  11. strUser="Computer;UserName;Connected?;Suspect?"
  12. Withrst'fillsRecordset(rst)withUserListdata
  13. DoUntil.EOF
  14. intUser=intUser+1
  15. ForEachfldIn.Fields
  16. varValue=fld.Value
  17. 'SomeofthereturnvaluesareNull-TerminatedStrings,if
  18. 'sostripthemoff
  19. IfInStr(varValue,vbNullChar)>0Then
  20. varValue=Left(varValue,InStr(varValue,vbNullChar)-1)
  21. EndIf
  22. strUser=strUser&";"&varValue
  23. Next
  24. .MoveNext
  25. Loop
  26. EndWith
  27. Me!txtTotalNumOfUsers=intUser'Total#ofUsers
  28. 'SetupListBoxParameters
  29. Me!lstUsers.ColumnCount=4
  30. Me!lstUsers.RowSourceType="ValueList"
  31. Me!lstUsers.ColumnHeads=False
  32. lstUsers.RowSource=strUser'populatetheListBox
  33. 'Routinecleanupchores
  34. Setfld=Nothing
  35. Setrst=Nothing
  36. Setcnn=Nothing
  37. EndFunction
  38. PrivateSubForm_Open(CancelAsInteger)
  39. CallGenerateUserList
  40. EndSub
  41. PrivateSubForm_Timer()
  42. CallGenerateUserList
  43. EndSub

Dec 22 '14 #1

Subscribe Post Reply

2 Why Am I Getting Runtime Error 3251? - Microsoft Access (2) 3566 Why Am I Getting Runtime Error 3251? - Microsoft Access (3)

twinnyfo

3,653 Why Am I Getting Runtime Error 3251? - Microsoft Access (5) Expert Mod 2GB

andigirlsc,

I use a slightly different version of this code:

Expand|Select|Wrap|Line Numbers

  1. OptionCompareDatabase
  2. OptionExplicit
  3. 'SetsomeConstantsandPublicVariables
  4. PrivateConstdbLockFileAsString="\\NetworkLocation\NetworkFolder\DatabaseName.laccdb"
  5. PrivateSubCurrentUsers()
  6. OnErrorGoToEH
  7. DimstrCurrentUsersAsString
  8. DimstrUserStringAsString
  9. DimintFileNumberAsInteger
  10. DimLineofTextAsString
  11. DimintPointerAsInteger
  12. intFileNumber=FreeFile
  13. IffIsFileDir(dbLockFile)Then
  14. OpendbLockFileForInputAs#intFileNumber
  15. Me.txtLockFileContents=""
  16. strCurrentUsers=""
  17. strUserString=""
  18. DoWhileNotEOF(intFileNumber)
  19. 'Readeachlineofthetextfileintoasinglestringvariable.
  20. LineInput#intFileNumber,LineofText
  21. WhileLen(LineofText)>0AndLen(LineofText)>=62
  22. intPointer=1
  23. DoWhileMid(LineofText,intPointer,1)<>""
  24. intPointer=intPointer+1
  25. Loop
  26. strUserString=Left(LineofText,intPointer-1)
  27. strCurrentUsers=IIf(Len(strCurrentUsers)=0,strUserString,_
  28. strCurrentUsers&vbCrLf&strUserString)
  29. LineofText=Right(LineofText,Nz(Len(LineofText)-62,0))
  30. Wend
  31. Loop
  32. Close#intFileNumber
  33. Me.txtLockFileContents=strCurrentUsers
  34. Else
  35. Me.txtLockFileContents="NoCurrentUsers"
  36. EndIf
  37. ExitSub
  38. EH:
  39. MsgBox"TherewasanerrorfindingallCurrentUsers."&_
  40. "PleasecontactyourDatabaseAdministrator.",vbCritical,"Error!"
  41. ExitSub
  42. EndSub
  43. PrivateFunctionfIsFileDir(strPathAsString,OptionallngTypeAsLong)AsInteger
  44. OnErrorResumeNext
  45. 'Checktoseeiffileexists
  46. fIsFileDir=Len(Dir(strPath,lngType))>0
  47. 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 Why Am I Getting Runtime Error 3251? - Microsoft Access (6)

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

  1. SubCurrentUsers()
  2. DimstrCurrentUsersAsString
  3. DimstrUserStringAsString
  4. DimintFileNumberAsInteger
  5. DimLineofTextAsString
  6. DimintPointerAsInteger
  7. DimdbLockFileAsString
  8. intFileNumber=FreeFile
  9. dbLockFile=CurrentProject.Path&"\"&CurrentDb.Name
  10. OpendbLockFileForInputAs#intFileNumber
  11. strCurrentUsers=""
  12. strUserString=""
  13. DoWhileNotEOF(intFileNumber)
  14. 'Readeachlineofthetextfileintoasinglestringvariable.
  15. LineInput#intFileNumber,LineofText
  16. WhileLen(LineofText)>0AndLen(LineofText)>=62
  17. intPointer=1
  18. DoWhileMid(LineofText,intPointer,1)<>""
  19. intPointer=intPointer+1
  20. Loop
  21. strUserString=Left(LineofText,intPointer-1)
  22. strCurrentUsers=IIf(Len(strCurrentUsers)=0,strUserString,_
  23. strCurrentUsers&vbCrLf&strUserString)
  24. LineofText=Right(LineofText,Nz(Len(LineofText)-62,0))
  25. Wend
  26. Loop
  27. Close#intFileNumber
  28. MsgBoxstrCurrentUsers
  29. 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 project—planning, coding, testing,...

Career Advice

Couldn’t 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.

Why Am I Getting Runtime Error 3251? - Microsoft Access (2024)

References

Top Articles
Latest Posts
Article information

Author: Margart Wisoky

Last Updated:

Views: 5961

Rating: 4.8 / 5 (78 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.