hi,
I have a problem with trying to find a way to allow many different sql statements to combine into a final requery.. I have played with this for about 4 days and cannot find a way to achieve the outcome. I am not sure if it is even possible.
Here is the scenario:
At present I have one form that contains 4 combo boxes. 2 of the combo boxes are dynamic in nature (the list provided does change), 2 of the combo boxes are static in nature but each selection made by the client actually uses a different query. But all queries are coming from the same database.
So as of now if the client selects to see all the transactions where they earned income by cash they select the appropriate combo box, select the method (cash) and the transactions appear on the screen... Nothing special so far, this is a standard type of use for a combo box....
I have another two combo boxes that have up to 15 static selections that all return different transactions depending on what is selected.. All of the four combo boxes work by themselves on there own without any input from each other.
But now I want to also be able to refine the searches even further where each combo box can be combined with each other.
For example; Lets say they select all income by cash from one of the combo boxes, but they can also make another selection from another combo box selecting NewYork. This means that they now how a query of all Cash Transactions made in NewYork.
This may seem simplistic enough but I have a total of 4 combo boxes combining some 15 to 20 different scenarios and combination's which can easily be requested at the click of a mouse. Creating an IF Statement for two combo boxes is fine as you can arrange that easy enough, but to get to 4 combo boxes and all the different selections could see a huge tangles mess of if statements, which is not practical and almost impossible to attempt to figure out.
This is a typical query when selected from one of my combo boxes (although I have shortened the where statement here to make it easier for you to see)
strSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.date >=[Forms]![income form]![btdate1] And INCOMENEW.[income method]= [Forms]![income form]![combo103];"
Forms![income form]![IncomeSubForm].Form.RecordSource = strSQL
Forms![income form]![IncomeSubForm].Form.Requery
There are up to 20 different queries over the 4 combo boxes..
What I am hoping for is a way to combine the selection into one end product.. Lets say I used 4 combo boxes each returning statements such as:
oneSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.date >=Forms![mainmenu]![incomedate] and INCOMENEW.[Category]= [Forms]![incomeform]![combo163];"
twoSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.date >=[Forms]![incomeform]![btdate1] And INCOMENEW.incomemethod= [Forms]![incomeform]![combo103];"
threeSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.[invoices]= [Forms]![incomeform]![combo123];"
fourSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.[month]= [Forms]![incomeform]![combo103] and INCOMENEW.employee= [Forms]![incomeform]![number] ;"
is there a way to combine all four query results... It is easy enough for me to pass and of the selections from any of the 4 combo boxes as I am already doing that with the selection using the existing IF Statements as they are already being used with the indivdual queries.. so I already know what each selection is. Can I combine them somehow:
example:
alljoinedSQL = oneSQL and twoSQL and threeSQL and fourSQL
combinedSQL = "SELECT * FROM INCOMENEW " & _
"WHERE alljoinedSQL;"
Forms![income form]![IncomeSubForm].Form.RecordSource = combinedSQL
Forms![income form]![IncomeSubForm].Form.Requery
I hope I have explained the above enough.. as i said I have spend days on this, reading and testing and I could do a massive arrangement of IF Statements but there has to be an easier way.. what do you think, is this possible
thanks
I have a problem with trying to find a way to allow many different sql statements to combine into a final requery.. I have played with this for about 4 days and cannot find a way to achieve the outcome. I am not sure if it is even possible.
Here is the scenario:
At present I have one form that contains 4 combo boxes. 2 of the combo boxes are dynamic in nature (the list provided does change), 2 of the combo boxes are static in nature but each selection made by the client actually uses a different query. But all queries are coming from the same database.
So as of now if the client selects to see all the transactions where they earned income by cash they select the appropriate combo box, select the method (cash) and the transactions appear on the screen... Nothing special so far, this is a standard type of use for a combo box....
I have another two combo boxes that have up to 15 static selections that all return different transactions depending on what is selected.. All of the four combo boxes work by themselves on there own without any input from each other.
But now I want to also be able to refine the searches even further where each combo box can be combined with each other.
For example; Lets say they select all income by cash from one of the combo boxes, but they can also make another selection from another combo box selecting NewYork. This means that they now how a query of all Cash Transactions made in NewYork.
This may seem simplistic enough but I have a total of 4 combo boxes combining some 15 to 20 different scenarios and combination's which can easily be requested at the click of a mouse. Creating an IF Statement for two combo boxes is fine as you can arrange that easy enough, but to get to 4 combo boxes and all the different selections could see a huge tangles mess of if statements, which is not practical and almost impossible to attempt to figure out.
This is a typical query when selected from one of my combo boxes (although I have shortened the where statement here to make it easier for you to see)
strSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.date >=[Forms]![income form]![btdate1] And INCOMENEW.[income method]= [Forms]![income form]![combo103];"
Forms![income form]![IncomeSubForm].Form.RecordSource = strSQL
Forms![income form]![IncomeSubForm].Form.Requery
There are up to 20 different queries over the 4 combo boxes..
What I am hoping for is a way to combine the selection into one end product.. Lets say I used 4 combo boxes each returning statements such as:
oneSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.date >=Forms![mainmenu]![incomedate] and INCOMENEW.[Category]= [Forms]![incomeform]![combo163];"
twoSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.date >=[Forms]![incomeform]![btdate1] And INCOMENEW.incomemethod= [Forms]![incomeform]![combo103];"
threeSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.[invoices]= [Forms]![incomeform]![combo123];"
fourSQL = "SELECT * FROM INCOMENEW " & _
"WHERE INCOMENEW.[month]= [Forms]![incomeform]![combo103] and INCOMENEW.employee= [Forms]![incomeform]![number] ;"
is there a way to combine all four query results... It is easy enough for me to pass and of the selections from any of the 4 combo boxes as I am already doing that with the selection using the existing IF Statements as they are already being used with the indivdual queries.. so I already know what each selection is. Can I combine them somehow:
example:
alljoinedSQL = oneSQL and twoSQL and threeSQL and fourSQL
combinedSQL = "SELECT * FROM INCOMENEW " & _
"WHERE alljoinedSQL;"
Forms![income form]![IncomeSubForm].Form.RecordSource = combinedSQL
Forms![income form]![IncomeSubForm].Form.Requery
I hope I have explained the above enough.. as i said I have spend days on this, reading and testing and I could do a massive arrangement of IF Statements but there has to be an easier way.. what do you think, is this possible
thanks