SyntaxSocialist
Registered User.
- Local time
- Today, 11:35
- Joined
- Apr 18, 2013
- Messages
- 109
I've got a form (frmEdit) that allows users to (1) search tblMain, (2) view those results in a subform, and (3) view the current record in a set of bound controls.
I want to add code for a button to run a query (in table view) based on the user's search. Since every search will be a little bit different and there would be an infinite number of combinations of search criteria, I'm thinking I want to use a temporary QueryDef object. Maybe. I'm not totally sure... So how do I make that work? What I've got so far looks like:
So really, I just need to figure out what do with this dynamically constructed SQL in order to allow the user to run a query based on it with a click of the button.
I want to add code for a button to run a query (in table view) based on the user's search. Since every search will be a little bit different and there would be an infinite number of combinations of search criteria, I'm thinking I want to use a temporary QueryDef object. Maybe. I'm not totally sure... So how do I make that work? What I've got so far looks like:
Code:
Private Sub btnRunQuery_Click()
Dim mySQL As String
Dim strSel As String
Dim strWhere As String
'Build SELECT Statement (strSel) based on user input (checkboxes) [B][DONE][/B]
'Build WHERE clause (strWhere) based on user input [B][DONE][/B]
'Build mySQL [B][DONE][/B]
mySQL = "SELECT " & strSel & "FROM tblMain " & "WHERE " & strWhere
'Run a query based on mySQL [COLOR="Red"][B][GREAT MYSTERY OF LIFE][/B][/COLOR]
End Sub
So really, I just need to figure out what do with this dynamically constructed SQL in order to allow the user to run a query based on it with a click of the button.