VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is a simple code to display column contents from access database and display it on the listbox

by Suresh (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 3rd September 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This is a simple code to display column contents from access database and display it on the listbox. Then from there U can click on the

API Declarations


' 1. List box
' 2. command button
' 3. text box


Rate This is a simple code to display column contents from access database and display it on the listbox




Dim OldDb As Database, NewSnap As Recordset, OldWs As Workspace
Dim rcset As Recordset
Set OldWs = DBEngine.Workspaces(0)

' assume your database is located at C:\inventory1\db2.MDB 
Set OldDb = OldWs.OpenDatabase("C:\inventory1\db2.MDB")

' assume the record that u going to work with is Customers
Set rcset = OldDb.OpenRecordset("Customers", dbOpenTable)

' this will get custid field from customers table and load it to the 
' listbox 

Set rcset = OldDb.OpenRecordset("select Custid from Customers ")
rcset.OpenRecordset


While Not rcset.EOF
  Dim i As Integer
   For i = 0 To rcset.RecordCount
   
   i = rcset("Custid")
     List1.AddItem i
      rcset.MoveNext
       Next i
Wend

MsgBox rcset.RecordCount
End Sub


Private Sub List1_Click()

Dim a
a = List1.ListIndex 
text1 = List1.List(X) 
End Sub


Download this snippet    Add to My Saved Code

This is a simple code to display column contents from access database and display it on the listbox Comments

No comments have been posted about This is a simple code to display column contents from access database and display it on the listbox. Why not be the first to post a comment about This is a simple code to display column contents from access database and display it on the listbox.

Post your comment

Subject:
Message:
0/1000 characters