Results 1 to 2 of 2
  1. #1
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138

    Unhappy ADODB.Connection yields "User-defined type not defined" error

    This is my connection sub:


    Sub InitDBConnect()
    Dim ConnectDB As ADODB.Connection
    Dim strDBPath As String
    Dim rst As ADODB.Recordset

    strDBPath = "X:\Operations\Manufacturing\Root Cause Analysis\RCAdbBE1.mdb"

    ' Initialize Connection object
    Set ConnectDB = New ADODB.Connection
    ' Specify Microsoft Jet 4.0 Provider and then open the
    ' database specified in the strDBPath variable.
    With ConnectDB
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .Open strDBPath
    '*** Where code for data would go if not in Sub ***
    End With


    Set rst = New ADODB.Recordset
    rst.Open _
    Source:=RCAData, _
    ActiveConnection:=ConnectDB, _
    CursorType:=adOpenDynamic
    '*** Where close and reset would go if not in Sub ***
    End Sub

    I call this in various subs, then close it at the end of the sub. Any help would be greatly appreciated. Should I be passing the recordset to the other sub? I am completely at a loss here and fear that I am in over my head.




  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Why do you need to do this? Why not just set links to the other db tables?

    Which line triggers the error?

    Does this work from any of the subs that call it? I believe the connection and recordset will both close when the InitDBConnect procedure ends.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 06-08-2012, 09:08 AM
  2. Replies: 1
    Last Post: 04-30-2012, 10:09 AM
  3. Replies: 1
    Last Post: 02-22-2011, 06:10 AM
  4. "Too many fields defined" error
    By Matthieu in forum Queries
    Replies: 1
    Last Post: 01-28-2010, 08:55 PM
  5. Error: "User-defined type not defined"
    By mastromb in forum Programming
    Replies: 10
    Last Post: 01-08-2010, 02:57 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums