Hi all,
Need some advice as to the best method to perform a long intrinsic access query through vba. The access query I'm refering to was originally created using access. This query feeds a report. My task is to split up this report into sub reports.
What I'm thinking of doing is running the same select query through vba but not return all records as the original but instead do some filtering. I'm doing this via a recordset rs. Then I generate the report from this new recordset.
Here's what I have:
Is this approach good? Can someone recommend a better way to do this? I have not finished doing the above. I'm struggling with the Select Query string because it is so long. That is why I decided to post this. Is there a way I can utilize the Access query that it is already created??
Thanks in advance and Happy New Year!
Need some advice as to the best method to perform a long intrinsic access query through vba. The access query I'm refering to was originally created using access. This query feeds a report. My task is to split up this report into sub reports.
What I'm thinking of doing is running the same select query through vba but not return all records as the original but instead do some filtering. I'm doing this via a recordset rs. Then I generate the report from this new recordset.
Here's what I have:
Code:
Dim sqlstring As String
Dim dbCurrent As Database
Dim rs As DAO.Recordset
Set dbCurrent = CurrentDb()
sqlstring = "........ 'This is the long query!!!
'My idea is to pass a value to the field I will be doing the filter on. Do a For Loop for all values.
Set rs = dbCurrent.OpenRecordset(sqlstring)
'***Output the report here!!!
rs.Close
Set rs = Nothing
Set dbCurrent = Nothing
Is this approach good? Can someone recommend a better way to do this? I have not finished doing the above. I'm struggling with the Select Query string because it is so long. That is why I decided to post this. Is there a way I can utilize the Access query that it is already created??
Thanks in advance and Happy New Year!