Pulling data from database

G

Guest

Hey all,
Once again I'm back asking for help.
I have a form were my dad enters data about fruit he is taking to the
farmers market. It then goes to the database. When he returns home I would
like to create a form that allows him to choose from a combo box the market
he attended would probable need to enter the data as well. Then from his
choice, in a list box the info he entered into the database would come up for
thatparticular Market and date. It would contain the differant fruit taken, #
of boxes, price/lb. Looking at this info., he would add any waste, unsold
boxes or change the price/lb.
So, the question. I have no idea how to get the info into the list box.
Example:
He chooses Pico (market) 5-6-05 (date)
In the list box pulling from the database up pops:
ID Fruit Variety Market Boxes Taken Weight
Price/LB. Etc.
4 Grapes Pico 15 10.25
3.0
6 Peaches Pico 10 10.
2.25
12 Cherries Pico 3 8
6.00
etc.

Any ideas? Thank you so much in advance. Is it possible to change the info
in the listbox? Thanks again, Jennifer
 
T

Tom Ogilvy

The listbox should have no rowsource assignment

assume the market name is in column A and the remainder of the data to the
right

Private Sub Userform_Initialize()
Dim rng as Range, cell as Range
Dim i as Long
Listbox1.ColumnCount = 8
set rng = Worksheets("Data").Range("A1").CurrentRegion
set rng = rng.offset(1,0).Resize(rng.rows.count,1)
for each cell in rng
if cell.Value = Combobox1.Value then
listbox1.AddItem cell.offset(0,1)
for i = 1 to 7
listbox1.List(listbox1.Listcount-1,i) = cell.offset(0, i + 1).Value
Next
End if
Next

End sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top