Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Location
    India
    Posts
    6

    Post Unanswered: Not able to Update records using rs.update function of Access visual basic

    Dear friends,
    I'm trying to create a form in MS Access 2000 which would enable me to save the newly entered records in the already existing table.
    I am trying to use the rs.update method & have written the following code, but neither am I facing any error messages nor the new record is being entered.
    Please help me out or else my Manager would fire me.....

    Event code for the cmdUpdate button's click event :-

    Private Sub cmdUpdate_Click() 'cmdUpdate is Update button

    ConnectRecord 'method to connect to the database
    rs.MoveLast

    txtNew.SetFocus
    'MsgBox rs(1).Value
    'rs(1) = txtNew.Text


    txtSecName.SetFocus 'text box to accept name
    rs(2) = txtSecName.Text


    txtSecSym.SetFocus 'text box to accept symbol
    rs(3) = txtSecSym.Text


    txtSecType.SetFocus 'text box to accept type
    rs(4) = txtSecType.Text


    txtShOwn.SetFocus 'text box to accept ownership
    rs(5) = txtShOwn.Text
    rs.Update



    End Sub

  2. #2
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: Not able to Update records using rs.update function of Access visual basic

    The Problem i suspected in that ur just UPDATING the last REcord in this table but ur not adding New record into it.You should use rs.AddNew instead of rs.MoveLast
    So your code shoud look like this
    ConnectRecord 'method to connect to the database
    rs.AddNew

    txtNew.SetFocus
    'MsgBox rs(1).Value
    'rs(1) = txtNew.Text


    txtSecName.SetFocus 'text box to accept name
    rs(2) = txtSecName.Text


    txtSecSym.SetFocus 'text box to accept symbol
    rs(3) = txtSecSym.Text


    txtSecType.SetFocus 'text box to accept type
    rs(4) = txtSecType.Text


    txtShOwn.SetFocus 'text box to accept ownership
    rs(5) = txtShOwn.Text
    rs.Update



    End Sub [/SIZE][/QUOTE]

  3. #3
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: Not able to Update records using rs.update function of Access visual basic

    instead of using rs(1)=txtnew.text
    use
    rs![ColumnName]= txtNew.Text

Posting Permissions

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