Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box or datagrid

Status
Not open for further replies.

Zbob

MIS
Apr 25, 2002
94
US
What is the simpliest way to display results of a recordset?

I have used the get string method to display the results, but there are no collum headings.

I want a basic datagrid, like an access query would display.

I have been reading about flexgrid and list boxes, but am not clear on how to display the data in the list box.

Thanks
 
You can use a listbox and set the columnheaders property to true. To populate listbox you can use the me.listbox.rowsource "Select * from Table" command. Or if you change the record source to value list you can use the
me.listbox.additem "whatever" method. To make the listbox look exactly like the access query, i recommend using the listview 6.0 active x control. If this is what you want let me know, I will try to help you out. Later and good luck.
 
Thanks for the help

I have only the first row of data showing up.

How do I loop thru the recordset to show all data.



Sqls = "Select [Bin Master]![Bin Loc], [Bin Master]![Bin No], " _
& "[Bin Master]![Qty on Hand] from [Bin Master]" _
& " where [item no] = '" & Item & "'"

RS.Open Sqls, Macola, adOpenforward, adLockReadOnly, adCmdText


Me.MListBox1.AddItem "Item" & " Loc" & " Bin" & " Qty"

Me.MListBox1.AddItem Item & " " & RS.Fields(0) & " " & RS.Fields(1) _
& " " & RS.Fields(2)
 
I used the following but my collums are not lining up any ideas to clean this up.

Sqls = "Select [Bin Master]![Bin Loc], [Bin Master]![Bin No], " _
& "[Bin Master]![Qty on Hand] from [Bin Master]" _
& " where [item no] = '" & Item & "'"

RS.Open Sqls, Macola, adOpenforward, adLockReadOnly, adCmdText


Me.MListBox1.AddItem "Item" & " Loc" & " Bin" & " Qty"
Do While Not RS.EOF

Me.MListBox1.AddItem Item & " " & RS.Fields(0) & " " & RS.Fields(1) _
& " " & RS.Fields(2)
RS.MoveNext
Loop
 
Zbob, simplist way is to use the rowsource property of the list box.

In properties make sure.

ROWSOURCETYPE = TABLE/QUERY
COLUMNHEADS = YES
COLUMNCOUNT = NUMBER OF COLUMNS YOU WANT
COLUMNWIDTHS = WIDTH OF EACH COLUMN 1.7;1.5; ETC ETC.

UTILIZE THE ROWSOURCE COMMAND

ME.MLISTBOX1.ROWSOURCE = "SELECT FIELDS FROM TABLE WHERE ITEM = WHATEVER"

Fields is the name of your fields, * for all
Table is the table name.


Put in the On Load Event of your form, use the
me.mlistbox1.requery method to requery the box. To use a loop and multiple columns I am going to suggest the listview control, but it is more coding. Let me know.
Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top