Solved

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

Posted on 2011-09-02
6
214 Views
Last Modified: 2012-05-12
Hi,

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.
0
Comment
Question by:Jimmy_inc
6 Comments
 
LVL 39

Assisted Solution

by:lcohan
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.
0
 
LVL 50

Assisted Solution

by:Lowfatspread
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.

0
 
LVL 42

Accepted Solution

by:
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.    
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 50

Expert Comment

by:Lowfatspread
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...
0
 
LVL 26

Assisted Solution

by:Nick67
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
http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_6692-Overcoming-unbound-continuous-forms-limitations-by-staging-data.html
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
CopyFromRecordset
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
FileSystemObject

and that's not even touching Pivot.

Deep man, deep.
0
 

Author Comment

by:Jimmy_inc
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:

DoCmd.TransferDatabase
DoCmd.TransferSpreadsheet

again thanks all for your avice it will save me hours of time.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now