Solved list box selection to show results in another listbox

ahmad_rmh

Member
Local time
Today, 12:44
Joined
Jun 26, 2022
Messages
243
I am trying to show results in a list box as per the selection in the list box.

for example:

List Box 1:
Current Stock
Received Stock
Transferred Stock

List Box 2:

List box 2 should have to show results as per the selection.

I have attached the screenshots.

How to get the solution.
Code:
Private Sub btnInventoryManagement_Click()
    Me.DynamicList.RowSource = "Select * from MasterTables where MasterTablesPK>3;"
    Me.DynamicList.ColumnCount = 3
    Me.DynamicList.ColumnHeads = False
    Me.DynamicList.ColumnWidths = "0;3.1042cm;0"
End Sub

Private Sub DynamicList_Click()
    If Me.DynamicList.RowSource = "Select * from MasterTables where MasterTablesPK>3;" Then
    Me.DynamicList1.RowSource = "SELECT ItemsPK, ItemsListName, CurrentStock, Nz([Opening Balance],0) AS Opening, Nz([NetPurchases],0) AS Purchases, Nz([NetTransfers],0) AS Transfers, Nz([MonthlyAdjustments],0) AS Adjustments, Round(Nz([NetTransfers],0)/Day(Date())*-1,2) AS AvgUsage FROM qryStockSummary;"
    Me.DynamicList1.ColumnCount = 8
    Me.DynamicList1.ColumnHeads = True
    Me.DynamicList1.ColumnWidths = "0;8cm;3cm;3cm;3cm;3cm;3cm;3cm"
    End If
End Sub

The problem is dynamiclist rowsource is not working if i am trying as under

"Select * from MasterTables where MasterTablesPK=4;"

kindly suggest the solution.
 

Attachments

  • Capture1.JPG
    Capture1.JPG
    28.7 KB · Views: 213
  • Capture2.JPG
    Capture2.JPG
    47.5 KB · Views: 195
If you look up "Cascading Combo Boxes" in this forum I think you will find many threads that might help you. That is, if I understood your question, that might help. It is a commonly asked question. The SEARCH button is in the upper right.
 
It works with < or > operator but not not showing results with equal sign operator.
 
Any chance you mistakenly made MasterTablePK a shortText and not an integer? Common issue since short text is default.
 
Are you saying?
Code:
"Select * from MasterTables where MasterTablesPK>3;"
Works
But
Code:
"Select * from MasterTables where MasterTablesPK = 3;"
Does not work

Without seeing your code can only guess. But clearly you are making a mistake we cannot see. If MasterTablesPK is numeric it will work, so there is something going on you are not showing us.
 

Users who are viewing this thread

Back
Top Bottom