Results 1 to 2 of 2

Thread: how-save-listitem from listbox-to ms access-vb6

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2009
    Posts
    21

    how-save-listitem from listbox-to ms access-vb6

    here i attach the error msg.
    i had some item in listbox and i remove
    the duplicate item.i fnished this much with the help of ur vb forum
    ----------------------
    how save that listitem
    into ms access table?
    then how i retrieve that value?
    i try this codings.
    -----------
    Private Sub Command3_Click()
    rs1.Open "select * from table1 where nid = " & Trim(Text1.Text), con, adOpenDynamic, adLockOptimistic
    rs1.Fields("no") = Val(List1.Text) // save the item in table
    MsgBox "added"
    rs1.Update
    rs1.Close
    End Sub
    --------------
    //to retrieve the item
    Private Sub Command1_Click()
    rs1.Open "select * from table1 where nid = " & Trim(Text1.Text), con, adOpenDynamic, adLockOptimistic
    rs1.AddNew
    Text1.Text = rs1.Fields("nid")
    Text3.Text = rs1.Fields("no") //get that item form table
    rs1.Update
    rs1.Close
    ----------------
    please rectify the error

  2. #2
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: how-save-listitem from listbox-to ms access-vb6

    you forgot to addnew in this code
    Code:
    Private Sub Command3_Click()
    rs1.Open "select * from table1 where nid = " & Trim(Text1.Text), con, adOpenDynamic, adLockOptimistic
    rs1.AddNew
    rs1.Fields("no") = Val(List1.Text) // save the item in table
    MsgBox "added"
    rs1.Update
    rs1.Close
    End Sub
    and there i no need of red line in this code
    Code:
    //to retrieve the item
    Private Sub Command1_Click()
    rs1.Open "select * from table1 where nid = " & Trim(Text1.Text), con, adOpenDynamic, adLockOptimistic
    'rs1.AddNew
    Text1.Text = rs1.Fields("nid")
    Text3.Text = rs1.Fields("no") //get that item form table
    'rs1.Update
    rs1.Close

Posting Permissions

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



Click Here to Expand Forum to Full Width