Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user-defined error

Status
Not open for further replies.

abenitez77

IS-IT--Management
Oct 18, 2007
147
US
I am getting the error : "user-defined type not defined"

in this line:

Dim cn As New ADODB.Connection
 
Add a reference to the Microsoft ActiveX Data Object xy Library

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I did that and then when the function runs on the form...it closes my application..saying :

Problem signature:
Problem Event Name: APPCRASH
Application Name: MSACCESS.EXE
Application Version: 12.0.6535.5005
Application Timestamp: 4bf5c550
Fault Module Name: ACECORE.DLL
Fault Module Version: 14.0.4760.1000
Fault Module Timestamp: 4ba8fda7
Exception Code: c0000005
Exception Offset: 00008d2f
OS Version: 6.1.7600.2.0.0.16.7
Locale ID: 1033

Additional information about the problem:
LCID: 1033
Brand: Office12Crash
skulcid: 1033
 




hmmmmmm. Do ya think that your code might be relevant to post as well?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
'function reads the ".ldb" (locking database) file associated with the ACCESS database in which this function is run,
'and returns a list of the users who are listed in that ".ldb" file.

Public Function WhoIsInTheDatabaseLockFile() As String

' OUTPUTS A LIST OF USERS IN THE DATABASE:
' 1. COMPUTER NAME ("COMPUTER NAME")
' 2. LOGON NAME ("LOGIN_NAME")
' 3. WHETHER USER IS STILL CONNECTED TO THE DB (USER ID
' REMAINS IN .LDB FILE UNTIL LAST USER EXITS OR
' UNTIL THE SLOT IS CLAIMED BY ANOTHER USER)
' ("CONNECTED")
' 4. WHETHER USER'S CONNECTION TERMINATED UNDER NORMAL
' CIRCUMSTANCES ("SUSPECT_STATE")

' *** ADAPTED FROM MICROSOFT KNOWLEDGE BASE ARTICLE 285822

Dim cn As New ADODB.Connection
Dim dbs As DAO.Database
Dim xlngLoop As Long
Dim rs As New ADODB.Recordset
Dim strNewDataSource As String, strCNString As String, xTT As String
Dim strCurrConnectString As String, xstrUserArray As String

Const strDummyTableName As String = "tbl__DummyTable_KeepRecordsetOpen"
Const strDatabaseString As String = "DATABASE="
Const strDataSourceText As String = "Data Source="

On Error GoTo Err_Msg

xstrUserArray = ""
strCurrConnectString = CurrentProject.Connection
strCNString = Mid(strCurrConnectString, InStr(strCurrConnectString, _
strDataSourceText) + Len(strDataSourceText))
strCNString = Left(strCNString, InStr(strCNString, ";") - 1)

Set dbs = CurrentDb
strNewDataSource = dbs.TableDefs(strDummyTableName).Connect
strNewDataSource = Mid(strNewDataSource, InStr(strNewDataSource, _
strDatabaseString) + Len(strDatabaseString))
Debug.Print "File containing the data tables: " & strNewDataSource

cn.ConnectionString = Replace(strCurrConnectString, strCNString, _
strNewDataSource, 1, 1, vbTextCompare)
cn.Open

' The user roster is exposed as a provider-specific schema rowset
' in the Jet 4.0 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets

Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

'Output the list of all users in the designated database

Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
"", rs.Fields(2).Name, rs.Fields(3).Name

While Not rs.EOF
Debug.Print rs.Fields(0), rs.Fields(1), rs.Fields(2), rs.Fields(3)

MsgBox rs.Fields(0) & " " & rs.Fields(1) & " " & rs.Fields(2) & " " & rs.Fields(3)

For xlngLoop = 0 To 3
xTT = Trim(Nz(rs.Fields(xlngLoop), ""))
If Len(xTT) > 1 Then
If Right(xTT, 1) = Chr(0) Then xTT = Left(xTT, Len(xTT) - 1)
End If
xstrUserArray = xstrUserArray & xTT & strPipeDelimiterChar
Next xlngLoop

rs.MoveNext
Wend

If Len(xstrUserArray) > 0 Then xstrUserArray = Left(xstrUserArray, _
Len(xstrUserArray) - 1)
WhoIsInTheDatabaseLockFile = xstrUserArray

MsgBox xstrUserArray

Exit_Function:
On Error Resume Next
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
dbs.Close
Set dbs = Nothing
Exit Function

Err_Msg:
Debug.Print "Error occurred. Error number " & Err.Number & ": " & Err.Description
Resume Exit_Function

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top