Link to home
Start Free TrialLog in
Avatar of alsam
alsam

asked on

How to use recordset efficientlly in Excel VBA

Hi,
Generally i don't work a lot with Excel VBA but I've been assigned a task to create some reports in excel using VBA...
Your help would be appreciate a lot....
Namelly, I should get data from SQL Server database, and my concept would be to get all data from xyz table from SQL Server in ADO recordset and then to disconect from the database...
In terms to get data in excel spreadsheet I would create different userforms in order to provide end users to define parameters which will be used to filter data in previously loaded recordset and then represented on worksheet itself...
Unfortunytelly, I was not able to find any good example how to pass parameters in recordset to get data filtered...

Here is clarification what I would like to achieve:

1. step load recordset like connect to SQL Server database and execute query "Select * from my_table" in order to populate recordset (ok this is not the issue)
2. step - After end user define parameters on the user form then I should execute query against recordset from step 1 which would look like "Select * from recordset where parameter1 = 'My_value' and parameter2 in ('My_value2',''My_value3')"

Can anyone help me in order to provide me with the example how to make this working (if possiblle)..

Thanks a lot...
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alsam
alsam

ASKER

Ok rorya,
I just wanted expert opinion about this....generally my goal was to release resources by disconecting end user from the database (or to limit to the minimum possibble connection attempts as possibble)...
Anyway, with your suggested approach then I should not have problems and no further assistance would be required....I'm going to leave behind my original idea...
Ok, I would leave this question open just for a short while (until tomorrow) in case someone else has to share experience regarding the issue...
Thanks for your time and effort....