M
MenloP3
Hello,
I have a combo box that contains two material categories, Metal and Polymer.
Based on either selection, I want Query.MaterialSearch to update itself
after the user clicks on a button. However, I seem to keep getting errors
with trying to address "Query.MaterialSearch.RecordSource = strNewSQL". When
I run the filter, it seems like Access just skips the Select Case portion and
goes to the bottom.
*************
Const cstrOldSQL = "SELECT MaterialName, MaterialCategory, Supplier FROM
Query.MaterialSearch"
Dim strNewSQL As String ' variable to hold the new SQL string for the
RecordSource
comboMaterial.SetFocus
Select Case comboMaterial!optSortBy
Case Is = 1
' Filter for 'Metal' returns 1
strNewSQL = cstrOldSQL & " WHERE MaterialCategory = '1';"
Case Is = 2
' Filter for 'Polymer' returns 2
strNewSQL = cstrOldSQL & " WHERE MaterialCategory = '2';"
Case Else
' Handle the instance where an unexpected value is returned
strNewSQL = cstrOldSQL & ";"
End Select
Query.MaterialSearch.RecordSource = strNewSQL
Query.MaterialSearch.Requery
*************
Would anyone happen to have any pointers for me to correct this problem?
Any help would be grately appreciated.
Thank you for your time.
I have a combo box that contains two material categories, Metal and Polymer.
Based on either selection, I want Query.MaterialSearch to update itself
after the user clicks on a button. However, I seem to keep getting errors
with trying to address "Query.MaterialSearch.RecordSource = strNewSQL". When
I run the filter, it seems like Access just skips the Select Case portion and
goes to the bottom.
*************
Const cstrOldSQL = "SELECT MaterialName, MaterialCategory, Supplier FROM
Query.MaterialSearch"
Dim strNewSQL As String ' variable to hold the new SQL string for the
RecordSource
comboMaterial.SetFocus
Select Case comboMaterial!optSortBy
Case Is = 1
' Filter for 'Metal' returns 1
strNewSQL = cstrOldSQL & " WHERE MaterialCategory = '1';"
Case Is = 2
' Filter for 'Polymer' returns 2
strNewSQL = cstrOldSQL & " WHERE MaterialCategory = '2';"
Case Else
' Handle the instance where an unexpected value is returned
strNewSQL = cstrOldSQL & ";"
End Select
Query.MaterialSearch.RecordSource = strNewSQL
Query.MaterialSearch.Requery
*************
Would anyone happen to have any pointers for me to correct this problem?
Any help would be grately appreciated.
Thank you for your time.