943,809 Members | Top Members by Rank

Ad:
Jan 15th, 2009
0

want to populate the listbox with msaccess database table data

Expand Post »
hi there, i have a form in Vb6 and a msacess 2007 database connected using ADODC, on a form is a listbox that i want to populate with the table data from the database, the name of the database is Storenw and the table from which i want to access is sales with fields barcode,item and price. i have the following code in my form-load seem to be working because am not getting any error but in the listbox is showing nothing,.. what can i do? am new in this pls!

code:

Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim strConnectionString As String
Dim strSQL As String

On Error GoTo Handler:

strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Documents and Settings\Mateuss\My Documents\project\storenw.mdb;Persist Security Info=False"

strSQL = "select * from sales"

rs.Open strSQL, strConnectionString
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
barcode = rs.Fields(0).Value
item = rs.Fields(1).Value
price = rs.Fields(2).Value
Call AddToListBox(barcode, item, price)
rs.MoveNext
Loop
Else
MsgBox "Nothing found."
End If

My_Exit_Sub:
On Error Resume Next
rs.Close
Set rs = Nothing
Exit Sub
Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume My_Exit_Sub
End Sub

Private Sub AddToListBox(ByVal barcode As String, ByVal item As String, ByVal price As String)


End Sub
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jan 15th, 2009
0

Re: want to populate the listbox with msaccess database table data

it seems your AddToListBox procedure doesn't do anything.
vb Syntax (Toggle Plain Text)
  1. Private Sub AddToListBox(ByVal barcode As String, ByVal item As String, ByVal price As String)
  2. list1.additem(barcode & " " & item & " " & price)
  3. End Sub
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 15th, 2009
0

Re: want to populate the listbox with msaccess database table data

thanx Comatose, think i just got it now,.
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jan 15th, 2009
0

Re: want to populate the listbox with msaccess database table data

now there is another problem, how can i make the date in the list be in a table form, because wats showing now is just a list
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Userprofile
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Search a particular file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC