Results 1 to 4 of 4

Thread: edit a record

  1. #1
    Join Date
    May 2011
    Posts
    6

    Unanswered: edit a record

    Hello you all,

    I'm a starter in access programming and I am trying to edit a record on a table with a form. But I can't find the way to do that. I have a checkbox and I want to assign the value true to a field named fldresccontrato when it is selected. I also have a combo box, the user will select it to choose the record to be edited (it has the name of the clients but it stores the id). I have tried this code:



    Private Sub cmguardarresc_Click()
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Set db = CurrentDb
    Set rst = db.OpenRecordset("tblclientes", dbOpenDynaset)
    rst.FindFirst "rst!fldid = " & Me.Cbnome.Value
    With rst
    .Edit
    !fldresccontrato = Me.Ckresccontrato.Value
    .Update
    rst.Close
    End With
    End Sub


    When I run this the error 3070 is showed and it says that rst!fldid is not a valid field name or expression. But this field is stored on the table.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    It should be:
    Code:
    rst.FindFirst "fldid = " & Me.Cbnome.Value
    or something like that: you must provide the name of the column in the table or the query (see Access help about the FindFirst method).
    Have a nice day!

  3. #3
    Join Date
    May 2011
    Posts
    6
    Hello,

    It worked just fine! thank you Sinndho

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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