Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009
    Posts
    85

    Unanswered: Almost there, I think

    O.k, getting closer to understanding this ADO thing but not there yet. I have the below under a button click event, It say it is connected, but dose not execute the select statement. Any help would be appreciated, thanks Tim


    Private Sub Command0_Click()

    On Error GoTo ConnectionError

    'Declaire connection object variable
    Dim localconnection As ADODB.Connection
    Dim myRecordSet As New ADODB.Recordset

    myRecordSet.ActiveConnection = localconnection

    'Set current Access connection to Connection object Variable
    Set localconnection = CurrentProject.AccessConnection

    myRecordSet.Open "SELECT * FROM tblPartsFinished"

    MsgBox "Local Connection Successfully Established"
    Exit Sub

    ConnectionError:

    MsgBox "There was an Error Connecting to the DataBase." & Chr(13) _
    & Err.Number & ", " & Err.Description
    End Sub

  2. #2
    Join Date
    Aug 2003
    Location
    Bulgaria, Plovdiv
    Posts
    36

    Another ADO example without using recordset

    Public Sub UpdateConnectedTime(Optional ByVal lngTransactions As Long = 0, _
    Optional ByVal lngPermReqCounter As Long = 0)
    On Error Resume Next

    ' Update Connected Time, Transaction Counter and Permission Requests Counter
    ' Use with After Update Form
    mTransCounter = mTransCounter + lngTransactions
    mPermReqCounter = mPermReqCounter + lngPermReqCounter

    Dim conConnection As ADODB.Connection
    Dim StrSQL As String

    Set conConnection = CurrentProject.Connection

    StrSQL = " UPDATE [Users] " & _
    " SET [ConnectedTime] = '" & mConnectedTime.StrTime(True) & "'" & "," & _
    " [TransCounter]= " & mTransCounter & "," & _
    " [PermReqCounter]= " & mPermReqCounter & _
    " WHERE [UserID] = " & mUserID & ";"

    conConnection.Execute StrSQL, iAffected, adExecuteNoRecords

    WrapUp:
    conConnection.Close
    Set conConnection = Nothing

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •