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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic column count for listbox

Status
Not open for further replies.

maro009

Programmer
Mar 16, 2006
4
BE
hi all
"i'm new to vb programming"

i created empty list box in form with columncount 1

no i have 3 different select statemnt the will have different column result , is there is any way to set the columncount
here is the method

'customerNameCB = comboBox
'SearchB = Button
'productsCB = comboBox
'addressCB = comboBox

Private Sub SearchB_Click()
Me.SearchB = Me.SearchB.DefaultValue

Dim querystirng As String
resultList.ColumnHeads = True

querystirng = ""


If customerNameCB.Enabled = True And (customerNameCB.Value <> customerNameCB.DefaultValue) Then
querystirng = "select le_Order.Order_id, le_Order.OrderDate, orderline.ProductID, Product.Model, Product.[Description] from le_Order,orderline,product where le_Order.Order_id = orderline.orderid And orderline.ProductID = product.ProductID And le_Order.Customer_id ='2'"

ElseIf productsCB.Enabled = True And (productsCB.Value <> productsCB.DefaultValue) Then
querystirng = "select distinct le_Order.Order_id, le_Order.OrderDate, le_customer.CustomerName,le_customer.Adress,orderline.Quantity from le_Order,orderline,product,le_customer where le_Order.Order_id = orderline.orderid And le_Order.Customer_id =le_customer.customer_id And orderline.ProductID = '40';"

ElseIf addressCB.Enabled = True And (adressCB.Value <> addressCB.DefaultValue) Then
querystirng = "select le_Order.Order_id, le_Order.OrderDate from le_order "

End If


If (querystirng <> "") Then
resultList.RowSource = querystirng
End If

Me.SearchB = Me.SearchB.DefaultValue


End Sub

 
If you're talking about access then you may set the ColumnCount property in VBA.


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thx PHV

i'm talking about MS Acess 2003 pro

if i set the columnCount property from the that means i will have fix amount of columns , but as i said i want set the counts depends on the result so i have to set it in vb

is there is any code to set the columnCount of listBox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top