daniness
Well-known member
- Joined
- Feb 12, 2010
- Messages
- 49
- Programming Experience
- Beginner
Hello All,
Was wondering if I could please get some assistance with this. I have a frm1 and frm2. frm1 has a combobox, cboLocations, from which a location is selected and then the "Ok" button is clicked upon which frm2 loads. frm2 contains textboxes and other comboboxes, which all should populate based on the selection made on frm1. So far, I have frm2's textboxes populating properly with the respective info for the selected location, i.e. location name, phone, fax, email, etc. There are also 3 comboboxes, which need to populate with the corresponding info as well as show the other available items when you click on the dropdown. Right now, I have one of the comboboxes, cboDepot, being populated with the corresponding Depot for the Location being selected on frm1, but I also need it to list the other available depots. Any help with this would be greatly appreciated. The below is my code for this particular combobox:
Was wondering if I could please get some assistance with this. I have a frm1 and frm2. frm1 has a combobox, cboLocations, from which a location is selected and then the "Ok" button is clicked upon which frm2 loads. frm2 contains textboxes and other comboboxes, which all should populate based on the selection made on frm1. So far, I have frm2's textboxes populating properly with the respective info for the selected location, i.e. location name, phone, fax, email, etc. There are also 3 comboboxes, which need to populate with the corresponding info as well as show the other available items when you click on the dropdown. Right now, I have one of the comboboxes, cboDepot, being populated with the corresponding Depot for the Location being selected on frm1, but I also need it to list the other available depots. Any help with this would be greatly appreciated. The below is my code for this particular combobox:
VB.NET:
Private Sub FillDepotCombo()
Dim sql As String = "Select distinct depot.depot_name, depot.depot_refnbr, locations.site from depot inner join locations on depot.depot_refnbr = locations.depot_refnbr and Site ='" & frmLocations.cboLocations.SelectedItem().ToString() & "'"
Dim cmdCorrespDepot As New SqlCommand(sql, conn)
Dim daDepot As SqlDataAdapter = New SqlDataAdapter(cmdCorrespDepot)
Dim dsDepot As New DataSet
Dim dtDepot As New DataTable("Depot")
Dim depotNbr As Integer
daDepot.Fill(dsDepot, "Depot")
Dim drDepot As SqlDataReader = cmdCorrespDepot.ExecuteReader
'Read records
While drDepot.Read
cboDepot.Items.Add(drDepot("depot_name"))
depotNbr = drDepot("depot_refnbr")
End While
cboDepot.Text = cboDepot.Items(0).ToString
drDepot.Close()
cmdCorrespDepot.Cancel()
cmdCorrespDepot.Dispose()
End Sub