G
GONSALVR via AccessMonster.com
Hello All,
I'm having a problem with resorting a listbox. I have a combo-box where I
want my users to select come choices to sort by: eg: "Supplier Name", "Data
Souce" etc.
When the form is first loaded it is sorted by "Supplier Name"
On the change event of the combo-box I have the following code. However when
I run the statement:
Me.SupplierNameList.RowSource = strSQL
The form reloads and my listbox is empty with one row but all blank column
values. BTW I'm using a single select listbox with no Control Source
Thanks for your help.
**********************************************************************************************************
Private Sub ctl_SuppSortBy_Change()
Dim strSQL As String,
strSQL = "SELECT tbl_UniqueSupplierNameFinal.SupplierName,
tbl_UniqueSupplierNameFinal.DataSource,"
strSQL = strSQL + "tbl_UniqueSupplierNameFinal.EightA,
tbl_UniqueSupplierNameFinal.AustinTetraYN, tbl_UniqueSupplierNameFinal.WBES,"
strSQL = strSQL + "tbl_UniqueSupplierNameFinal.VETS,
tbl_UniqueSupplierNameFinal.UpdatedBy, tbl_UniqueSupplierNameFinal.
ModifiedDate"
If ctl_SuppSortBy.Value = "Data Source" Then
strSQL = strSQL + "FROM tbl_UniqueSupplierNameFinal ORDER BY
tbl_UniqueSupplierNameFinal.DataSource;"
Else
strSQL = strSQL + "FROM tbl_UniqueSupplierNameFinal ORDER BY
tbl_UniqueSupplierNameFinal.SupplierName;"
End If
Me.SupplierNameList.RowSource = strSQL
End Sub
I'm having a problem with resorting a listbox. I have a combo-box where I
want my users to select come choices to sort by: eg: "Supplier Name", "Data
Souce" etc.
When the form is first loaded it is sorted by "Supplier Name"
On the change event of the combo-box I have the following code. However when
I run the statement:
Me.SupplierNameList.RowSource = strSQL
The form reloads and my listbox is empty with one row but all blank column
values. BTW I'm using a single select listbox with no Control Source
Thanks for your help.
**********************************************************************************************************
Private Sub ctl_SuppSortBy_Change()
Dim strSQL As String,
strSQL = "SELECT tbl_UniqueSupplierNameFinal.SupplierName,
tbl_UniqueSupplierNameFinal.DataSource,"
strSQL = strSQL + "tbl_UniqueSupplierNameFinal.EightA,
tbl_UniqueSupplierNameFinal.AustinTetraYN, tbl_UniqueSupplierNameFinal.WBES,"
strSQL = strSQL + "tbl_UniqueSupplierNameFinal.VETS,
tbl_UniqueSupplierNameFinal.UpdatedBy, tbl_UniqueSupplierNameFinal.
ModifiedDate"
If ctl_SuppSortBy.Value = "Data Source" Then
strSQL = strSQL + "FROM tbl_UniqueSupplierNameFinal ORDER BY
tbl_UniqueSupplierNameFinal.DataSource;"
Else
strSQL = strSQL + "FROM tbl_UniqueSupplierNameFinal ORDER BY
tbl_UniqueSupplierNameFinal.SupplierName;"
End If
Me.SupplierNameList.RowSource = strSQL
End Sub