Find and Update Recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ceylon
    New Member
    • Jul 2010
    • 5

    #1

    Find and Update Recordset

    Hi

    I have following code to find the hashvalue in HashValue colunm and update the Time in BST column. But i breaks in (objRecordSet.F ields.Item("BST ime") = Time) here (**Edit Line #23 **). Pls HELP
    Code:
    Function UploadBST()
    
    'On Error Resume Next
    Dim objConnection As ADODB.Connection
    Dim objRecordSet As ADODB.Recordset
    Dim hashvalue1 As String
    
    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordSet = CreateObject("ADODB.Recordset")
    
    objConnection.Open _
        "Provider = Microsoft.Jet.OLEDB.4.0; " & _
            "Data Source =C:\Documents and Settings\Owner\My Documents\New.mdb;"
    
    objRecordSet.Open "SELECT * FROM TS", _
        objConnection, adOpenStatic, adLockOptimistic
    
    hashvalue1 = Environ("Username") & Date
    strCriteria = "HashValue = 'hashvalue1'"
    
    objRecordSet.Find strCriteria
    
    objRecordSet.Fields.Item("BSTime") = Time
    objRecordSet.Update
    
    
    objRecordSet.Close
    objConnection.Close
    
    
    End Function
    Last edited by NeoPa; Jul 6 '10, 11:23 AM. Reason: Please use the [CODE] tags provided.
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by Ceylon
    Hi

    I have following code to find the hashvalue in HashValue colunm and update the Time in BST column. But i breaks in (objRecordSet.F ields.Item("BST ime") = Time) here. Pls HELP

    Function UploadBST()

    'On Error Resume Next
    Dim objConnection As ADODB.Connectio n
    Dim objRecordSet As ADODB.Recordset
    Dim hashvalue1 As String

    Set objConnection = CreateObject("A DODB.Connection ")
    Set objRecordSet = CreateObject("A DODB.Recordset" )

    objConnection.O pen _
    "Provider = Microsoft.Jet.O LEDB.4.0; " & _
    "Data Source =C:\Documents and Settings\Owner\ My Documents\New.m db;"

    objRecordSet.Op en "SELECT * FROM TS", _
    objConnection, adOpenStatic, adLockOptimisti c

    hashvalue1 = Environ("Userna me") & Date
    strCriteria = "HashValue = 'hashvalue1'"

    objRecordSet.Fi nd strCriteria

    objRecordSet.Fi elds.Item("BSTi me") = Time
    objRecordSet.Up date


    objRecordSet.Cl ose
    objConnection.C lose


    End Function
    Try changing the Cursor Type:
    Code:
    objRecordSet.Open "SELECT * FROM TS", _
    objConnection, adOpenKeyset, adLockOptimistic

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Please describe more clearly what you mean by "It breaks". Is there an error message? What happens exactly?

      We shouldn't be spending extra time just trying to work out what your question means.

      Comment

      • Ceylon
        New Member
        • Jul 2010
        • 5

        #4
        Ok, Thanks for the info

        Comment

        • Ceylon
          New Member
          • Jul 2010
          • 5

          #5
          Originally posted by ADezii
          Try changing the Cursor Type:
          Code:
          objRecordSet.Open "SELECT * FROM TS", _
          objConnection, adOpenKeyset, adLockOptimistic
          this worked thanks

          Comment

          Working...