Dear Community, I am new with VBA, Programming a Access-Database. I try to create a query programmatically with a dynamic number and permutation of properties, Choosing by Checkboxes. The Problem is, that every Variation is possible. So My idea was to create a Variable that collect all expressions and then search in a table for it. An Example-Code is following
smyWert1 = "Select * from " & Me.Form.RecordSource & " where (([txt_Kategorie] = '" & Me.txt_Kategorie & "'))"
If ch_Wert = True Then
smyWert1 = "Select * from " & Me.Form.RecordSource & " where (([txt_Wert] = '" & Me.txt_Wert & "') And ([txt_Kategorie] = '" & Me.txt_Kategorie & "'))"
End If
My Idea is to replace the Expression (example: ([txt_Wert] = ' " & Me.txt_Wert & " ') ) with a variable, concatenate the expressions for all checked textboxes and at the end execute the select * from Command to search in the target-table.
I saw some tutorials to that topic but there was no solution for my problem. There was also the difference to the tutorials, that I have to set the expression in ' " instead of ".
It would be greatful if someone can help me with this problem. I think it couldn't be so difficult but I don't find a solution in a short term period.
With kind regards
Sönke Schuch
|