View Stored Proc Command Text in a Cell

Bench

Board Regular
Joined
Aug 27, 2009
Messages
134
Hi,

I'm working on a Macro that is working intermittently to change the Command Text in a Stored Proc connection property.

e.g. exec dbo.usp_ShepherdBonusDataBreakdown 'Sonya Taylor',7,2013

Changes to [SurveyorName] based upon 'Variables' Range "E4"

With Workbooks("Surveyor Statement V8.xlsm").Connections("115Points").OLEDBConnection
.CommandText = "exec dbo.usp_ShepherdBonusDataBreakdown '" & Worksheets("Variables").Range("E4").Value & "'," & Worksheets("Variables").Range("E3").Value & "," & Worksheets("Variables").Range("E2").Value
End With

As stated sometimes it works other times it doesn't.

What would be really useful would be to see the Command Text in a cell as there are several proc Text's changing based upon that value.

Is there a way to do this to save me going through DATA>Connections>Properties>Definition every time to check the macro has worked.

Any ideas?

Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You can use this to print it to the Immediate window:

Code:
Debug.Print .CommandText

or to put it in A1 on the ActiveSheet:

Code:
Range("A1").Value = .CommandText
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top