I have a search form which contains 2 listboxes. The first one lists all the customers and when the user picks a customer (On Click event) the second listbox displays all the jobs for that customer. lstCustName is populated from the Customer table with CustNo and CustName, bound on CustCode. lstJobName will be populated with JobNo and JobName when a customer is selected in ListBox1 as follows:
I also have a textbox on the form which is bound to CustCode (I thought my problems may stem from trying to pick up the selected custCode straight from lstCustName.
My problems are many and varied, so apologies in advance for the length.
1) When I drop lstJobName onto the form, I select these options:
So for now I am selecting "Remember the value for later use". The JobNo value must be passed back to the original form.
2) When I load the search form, the Customer listbox has the 1st record in the table selected as a default, although there is no value in the "Default Value" . Is it possible to have no selection in the listbox after populating it? I thought it may be a tab stop issue, so have made that No for the listboxes, but it makes no difference.
3) How do I check if no records are found for the Jobs list box (i.e. no jobs for a specific customer)?
TIA
Code:
lstJobName.RowSource = "SELECT Jobs.JobNo, Jobs.JobName FROM Jobs WHERE [Jobs].[CustCode]= CustCode ORDER BY Jobs.JobNo DESC"
I also have a textbox on the form which is bound to CustCode (I thought my problems may stem from trying to pick up the selected custCode straight from lstCustName.
My problems are many and varied, so apologies in advance for the length.
1) When I drop lstJobName onto the form, I select these options:
a) get values from a query containing the code above
b) Select JobNo and JobName as fields to display in listbox
c) Select JobNo as the unique identifier
When I select "Store that value in this field", the drop down list contains CustCode and CustName as options, not JobNo and JobName as I would expect? Why?So for now I am selecting "Remember the value for later use". The JobNo value must be passed back to the original form.
2) When I load the search form, the Customer listbox has the 1st record in the table selected as a default, although there is no value in the "Default Value" . Is it possible to have no selection in the listbox after populating it? I thought it may be a tab stop issue, so have made that No for the listboxes, but it makes no difference.
3) How do I check if no records are found for the Jobs list box (i.e. no jobs for a specific customer)?
TIA