Create an access application sourced from SQL stored procs to create 3 different files


the reason I have asked the whole is in case i can avoid any common pitfalls.. and will break this down into multiple q's if i have too.

I would like to have a form with a combobox in Access 2000 or Access 2003 which will display the names of the stored procedures I (or a user) have access to in my SQL 2005/2008 database.
Most likely be making this into an an MDE file. This would be distributed to around 5 users.

Once I have selected a stored procedure it will dynamically create additional comboboxes below, depending on how many and listing the with the optional parameters that I have specified in my stored procedure.

Once I have selected the parameters, I want to be able to choose

from radiobuttons

- Excel file then when clicking on a 'OK' button  this would export the results to a new .xls file that I would specify in the destination txtbox

- Access Database then when clicking on a 'OK' button  this would export the results to a new table in an .mdb file that I would specify in the destination txtbox

- Excel Pivot Table, this would allow additional form elements to be created allowing me to assign any of the fields returned by the stored procedure e.g.
Category1 to Page field
Category2 To Row Field
Category3 To Row field
Category4 to Column Field

And then I could choose a the data field and an aggregate function
e.g Count, SUM etc but more specifically Count UNIQUE that i could sent to the data area.

Then I could specify the destination xls file in a textbox then when clicking on a 'OK' button  this would create the new .xls file  that I would specify in the destination txtbox

any errors would end the procedure and write to a text file for debugging.

Is this asking to much? I realise the 1% inspiration 99% perspiration might very much apply to this.
Who is Participating?
dqmqConnect With a Mentor Commented:
The quick and dirty way is to design your app based on a few tables, for example, one to hold the names of procedures and a child table to hold the parameters needed by each procedure. Undoubtedly, more tables would be required, for example if each user has access to a different mix of procs.  

Then you dynamically "build" your form from that.  I do advise you that you cannot add controls to a form whilst the form is running--you must switch it to design mode, first. So to accomplish what you want, you either need a two-form model (form A builds and run form B) or a single form model with pre-defined controls that you hide/unhide as needed.

As your application matures, you may be able to replace some of the tables with views or procs that take advantage of SQL Server management views to retrieve proc names and parameter information from SQL Server's system tables.    
lcohanConnect With a Mentor Database AnalystCommented:
Why so complicated if you have SQL server I asumme you have SSRS so just use it and create reports based on your SQL stored procs record sets. The reports have a nice feature to export files in many different formats as well.
LowfatspreadConnect With a Mentor Commented:
and your question is?

The site is for answering questions/ giving guidance/advice
rather than having someone write applications for you....

you need to design you own tables to store the names of the stored procedures/ processes that
you will allow the users to execute, and define the parameter information that each will require...

... from a practical point of view you are likely to have procedures that you will not want the users to
execute directly (think sub functions...) but that from a pure database view point they could (will execute in the background) run.

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

i'd advise against using the internal management views directly use them as a base for your own
tables... that way you minimise you dependance on a specific version of sql server...
Nick67Connect With a Mentor Commented:
You could do this, but it would be very complex.
You need to ask yourself at the outset if it would be beyond your skillset.
You can look at my article about staging data here
When you first combobox is selected, you could use code to populate a 'temp' table with rows to capture the users input for each needful parameter
(Alternatively, you could pre-build that table if nothing in the sprocs changes  Give each sproc an 'ID' number and filter with result from the table accordingly.)
By binding to a table, you can use a continuous form and get away from bazillions of unbound controls or dynamically building a form.
After the combobox selection is made, the form requeries.
The user makes selections and hits a command button to carry out the actions.
The sprocs can be executed by passthrough queries, and as such, bound to subforms or used by Recordsets and dispatched by VBA code.

It's doable--but highly complex--and given that you are asking the question it will involve a VERY steep learning curve for you
You are looking at making sense of my article
Automating Excel
Creating Pass-through queries
Dynamically rewriting a passthrough query through VBA Querydef
Using a pass-through as the basis for a recordset
Make-table SQL statements
Automating Access to get a new mdb going

and that's not even touching Pivot.

Deep man, deep.
Jimmy_incAuthor Commented:
Thanks for all the advice.

I will either use SSRS or

The quick and dirty way based on a few tables

I will use pass through queries to exec the sprocs

After the combobox selection is made, the form requeries.

and then the following should help:


again thanks all for your avice it will save me hours of time.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.