ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pulling data from database (https://www.excelbanter.com/excel-programming/330991-pulling-data-database.html)

Jennifer

Pulling data from database
 
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

--
Though daily learning, I LOVE EXCEL!
Jennifer

Tom Ogilvy

Pulling data from database
 
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

--
Regards,
Tom Ogilvy


"Jennifer" wrote in message
...
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

--
Though daily learning, I LOVE EXCEL!
Jennifer





All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com