Results 1 to 8 of 8
  1. #1
    albe_ACC is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    8

    ADODB Problem

    Hello guys!
    I need to use an ADODB.command in a private subfunction.

    Dim cmd As New ADODB.Command
    Dim rst As ADODB.Recordset



    Access is returning me a compile error when I try to execute them.
    Same goes for ADODB.connection

    Am I using them in the wrong way?
    Thank you very much for your time

  2. #2
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    I would think you would need to show us the rest of the code such as the below examples from my database:

    Set rst = New ADODB.Recordset
    .
    .
    .
    With rst
    .ActiveConnection = CurrentProject.Connection
    .CursorType = adOpenStatic 'Allow forward and backward movement in recordset
    .LockType = adLockOptimistic 'Lock record after Update method is issued
    .Open strSQL

    ************************************************** ************
    Set cmd = New ADODB.Command
    Set cmd = cat.Views(strqryName).Command

  3. #3
    albe_ACC is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    8
    Here it is!
    The compiler stops at "Dim cmd As New ADODB.Command"

    Private Sub DA_Click()

    If Check() = True Then
    Exit Sub
    End If


    Dim ID_1 As Integer
    ID_1 = Me.Parent![Data]

    Dim ID_2 As Integer
    ID_2 = Me.Data2

    Dim strQuery As String
    Dim cmd As New ADODB.Command
    Dim rst As ADODB.Recordset
    Dim recordAffected As Long
    Set cmd.ActiveConnection = Application.CurrentProject.Connection

    strQuery = (omitted operations on ID_1 and ID_2)
    cmd.CommandText = strQuery
    Set rst = cmd.Execute(recordAffected)

    Set rst = Nothing

    Me.Refresh
    Me.Requery


    End Sub

  4. #4
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    I hesistate to say your way is wrong because I know there are certain things you can do as

    dim xxx as New yyyy.zzz

    but try this:

    dim cmd as ADODB.Command
    Set cmd = New ADODB.Command

  5. #5
    albe_ACC is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    8
    It does not seem to work either!
    The compiler stops when facing the "ADODB.Command".
    I'm a beginner, as u may have got...maybe do I have to somehow initialize the ADODB?

  6. #6
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Oh, duh I just remembered. Did you set a reference to the ADODB and/or ADOX libraries? In the VBA edit window click on Tools|References and scroll down, down, down and check the box next to the ADODB and ADOX libraries. In my Access 2007 I have the "Microsoft ActiveX Data Objects 2.8 Library" and "Microsoft ADO Extensions 2.8 for DDL and Security" libraries checked.

  7. #7
    albe_ACC is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    8
    Thank you very much Nicknameoscar, it worked
    Have a nice day!!!

  8. #8
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Awesome, you are quite welcome.

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

Similar Threads

  1. Connect to mysql with adodb
    By jacek_arwal in forum Programming
    Replies: 4
    Last Post: 09-04-2011, 10:56 PM
  2. ADODB Recrodset (Understanding)
    By danny2000 in forum Access
    Replies: 3
    Last Post: 07-12-2011, 06:00 AM
  3. ADODB Retrieve Value with SQL Help
    By kawi6rr in forum Programming
    Replies: 3
    Last Post: 05-07-2011, 02:03 PM
  4. Adodb
    By sassy in forum Programming
    Replies: 2
    Last Post: 10-26-2009, 06:40 PM
  5. Counting large ADODB recordsets
    By harpyopsis in forum Programming
    Replies: 3
    Last Post: 10-16-2009, 10:05 AM

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