Question:

Save listbox items in MS Access Database.

by Guest12038961  |  2 years, 7 month(s) ago

0 LIKES UnLike

Save listbox items in MS Access Database.

 Tags: Access, database, items, Listbox, ms, save

   Report

1 ANSWERS

  1. Ali Abdullah
    Hi There, Option Explicit Dim cn As ADODB.Connection Dim rec As ADODB.Recordset Private Sub list1_Click() Dim idu As String, esql As String idu = List1.Text esql = "select * from YourTableName" rec.Open (esql), cn, adOpenDynamic, adLockOptimistic rec.AddNew rec.Fields("FieldName") = idu rec.Update If Not rec.EOF Then rec.MoveNext rec.Close 'you can remove the item from the listbox here if you choose 'this will add the selected item of the listbox to the table End Sub Private Sub Form_Load() Set cn = New ADODB.Connection Set rec = New ADODB.Recordset cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\ravindra\My Documents\Test_1.mdb;Persist Security Info=False" 'change this line to point it to your database cn.Open End Sub Private Sub Form_Unload(Cancel As Integer) cn.Close Set cn = Nothing End Sub

Question Stats

Latest activity: 2 years, 7 month(s) ago.
This question has been viewed 432 times and has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions