Using Microsoft Query with a Stored Procedure

Earlier, we had blogged on how to create a refreshable report using VBA. Frequent GPUG contributor Steve Erbach pointed out that Victoria Yudin has a blog posting on how to do the same thing using Microsoft Query.

Having coded it both ways now I'm not sure which way is better. This technique below is longer to do (17 screen shots), but it avoids VBA which is bound to be a new technology for some people. I'd appreciate your comments.

This technique also queries the database and returns a list of all the tables and views so you have to sit and wait for a while to get that list... and then you don't need it. If you get the 'please wait' window just sit and wait it out. It might be a few minutes.

Victoria's original article is here. Our article here is written in our typical RAD style. Victoria's is more personable <smiles>.  

Our article was written against Office 2010.

I want to thank Steve for his input. You'd be surprised how few people take the time

Steve's words:

Victoria Yudin has addressed the use of stored procs with just one or two parameters without VBA. I also did an overly-long video series on YouTube showing how to implement the RM Historical Aged Trial Balance stored proc in a refex (REFreshable EXcel workbook).

Editors note:

If you're not a GPUG member, you're missing out.

Related Articles

... and you 'll find more on the Dynamics GP Menu

Create a stored procedure with parameters. Ours is called dd_ProjectWeeklyDetail and it has one parameter, the project number

Open Excel, on the Data tab choose From Other Sources > From Microsoft Query

 

Usually, the best choice here will be the Dynamics GP ODBC connection. BUT IF YOU DO... press the options button and select a database.

There are several methods to use for authentication. We're coding a demo so we'll use the 'sa' account (the password is never saved)

Here's that same window as above with the Option button pressed and the form expanded.

This is where we had to wait for quite a few minutes

Close this window

Choose Yes

 

Close this window

 

Click on the SQL button

 

 

Enter the stored procedure name as shown below. If you have several parameters code it like this: (?,?,?)

 

Choose OK

 

Enter a valid value for your parameter. We get an opportunity to rename the param later

You should have data here. Your stored procedure should be written in such a way that the field names look nice in the column headings.

Close this window. It's OK. Trust me.

 

We're going to do two things now, add the parameters and add the data. We have one parameter and it's going to go into cell B1, so we're going to start the report in cell A4.

After selecting A4, click on Properties

 

 

You can either allow Excel to prompt for the parameters on each refresh, or get them from the sheet. If you prompt, give it a proper name (like Project Number). We'll get the value from the sheet. Enter B1 in the text box as shown below.

Click OK

 

Click OK

All done.

 

 

Comments? Questions?

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences