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

Posted on 2011-09-02
Last Modified: 2012-05-12

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.
Question by:Jimmy_inc
LVL 39

Assisted Solution

lcohan earned 125 total points
ID: 36474771
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.
LVL 50

Assisted Solution

Lowfatspread earned 125 total points
ID: 36474861
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.

LVL 42

Accepted Solution

dqmq earned 125 total points
ID: 36475011
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.    
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

LVL 50

Expert Comment

ID: 36475360
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...
LVL 26

Assisted Solution

Nick67 earned 125 total points
ID: 36475796
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.

Author Comment

ID: 36486796
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.

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question