473,395 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Re: Pass an Access field as a parameter in link to SSRS or ASP?

(this is way easier in VB.Net -- but here is how to do it from Access)

'------------------------------------------------
Public Declare Function apiShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long

'***App Window Constants***
Public Const WIN_NORMAL = 1 'Open Normal
Public Const WIN_MAX = 3 'Open Maximized
Public Const WIN_MIN = 2 'Open Minimized

'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&

Sub RunReport()
Dim url As String, lRet As Long
url =
"http://yourServer/ReportServer?/rptDir/reportName&rs:Format=excel&Recor
dID=10007&UserID=steve"

lRet = apiShellExecute(hWndAccessApp, vbNullString, _
url, vbNullString, vbNullString, WIN_NORMAL)
End Sub

after ...rs:Format=excel... I have 2 parameters that I pass to my report
-- a recordID and a UserName. That is how you pass the parameters to
sql server reporting services from Access. It is actually the same in
VB.Net except you don't have to deal with the API function. I just use
a .Net web browser control in place of the API.
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 5 '08 #1
8 3006
Awesome!! Thanks!

I'm getting pretty good with Access... But I'm very new to VB.
Do I need to save this as a "Module"?
Also, how to I call up this link? Set it as a button from my form?
How do I get my parameter to pass into that link?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 6 '08 #2
I would place the API declaration in a Standard Module. This way you
can use the API function throughout the mdb. The rest of the code you
could put in a button on a form.

As for the URL - this is just a string. You build the url string. The
number of parameters is based on the query used to run the Sql Server
Reporting Services Report (rdl). You can have a textbox on your form in
Access for each parameter. The user fills in the textboxes then when
the User presses the button -- you build the url string like this:

'------------------------------------
Private Sub cmd1_click()
dim url as string

url =
"http://yourServer/ReportServer?/rptDir/reportName&rs:Format=excel&Recor
did=" & txtRecordID & "&userid=" & txtUserID

lRet = apiShellExecute(hWndAccessApp, vbNullString, _
url, vbNullString, vbNullString, WIN_NORMAL)
End Sub
'------------------------------------

be careful when creating the url because you will notice several "&"
symbols. The "&" inside the quotes belongs to the url. the other &
symbols are string concatenators for txtRecordID and txtUserID
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 6 '08 #3
Rich,
I really appreciate your help.
I setup the first one as a module, and then made the second one for my button.
I keep getting this "Compile Syntax" error though.
I'm so out of my league..

I created another "test" db to see if i could get the button to work..
But it keeps giving me the error.
http://img171.imageshack.us/img171/1...haccesszr8.jpg
Thoughts?
Am I close?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 6 '08 #4
Yes. Thanks for the pic - problem with the url string. I broke the
string apart so this should compile.

'------------------------------------
Private Sub cmd1_click()
dim url as string

url = "http://yourServer/ReportServer?/rptDir/" _
& "reportName&rs:Format=excel&Recordid=" _
& txtRecordID & "&userid=" & txtUserID

lRet = apiShellExecute(hWndAccessApp, vbNullString, _
url, vbNullString, vbNullString, WIN_NORMAL)
End Sub
'------------------------------------

Note: replace yourServer with the name of your actual server. And
replace rptDir with the name of the actual report directory that the rdl
gets published to. From the Reporting Services designer you can go to
Project properties and see where the rdl gets published to. From
Project/Properties copy the TargetServerURL text and also copy the
TargetFolder text

http://yourServer/ReportServer?/rptDir/

separate the TargetServerURL From the Target folder with "/" forward
slashes. Then copy the name of your report (rdl)

http://yourServer/ReportServer?/rptDir/yourRpt

then add
"http://yourServer/ReportServer?/rptDir/yourRpt
&rs:Format=excel&param1=12345&param2=somthing"

I wouldn't even bother using textboxes right now. Just hardcode some
known parameters and see if it works.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 6 '08 #5
Rich,
It worked!! You are awesome.

I got the parameter pulling from a text box too.
Man, I worked for hours (crazy right?) on this yesterday.. and got nowhere.

Thank you soooo much!!
Know any good resources to learn about this kind of programming?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 7 '08 #6
Grrrr!!!

So now, If I try to put a button like this into my live Access DB.. It keeps
giving me "Compile Error: Variable not Defined."
http://img529.imageshack.us/img529/2...rtpull2yp1.jpg

However, If i create a NEW form.. and put the same info in there.. the
report/link opens just fine.

I gotta be doing something wrong here. :(

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 7 '08 #7
"simpleton via AccessMonster.com" <u45284@uwewrote in message
news:8850d1ba82a79@uwe...
Grrrr!!!

So now, If I try to put a button like this into my live Access DB.. It
keeps
giving me "Compile Error: Variable not Defined."
http://img529.imageshack.us/img529/2...rtpull2yp1.jpg

However, If i create a NEW form.. and put the same info in there.. the
report/link opens just fine.

I gotta be doing something wrong here. :(

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1
You need to define lRet:

Dim lRet As Long

inside the procedure.
Aug 7 '08 #8
Aah, Perfect.

Thanks!! Now I'm working again.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 7 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Johansson | last post by:
Hello! I use method forName and newInstance in class Class like this instance = (GameFactory)(Class.forName(name).newInstance() ); Now to my question: Assume that name is GameFactory then I...
5
by: Don Seckler | last post by:
I have an update query that runs when a report closes. I have several reports that will need to run the update query with diferent criteria. I'd like to simply make the criteria change in the...
9
by: Alan Lane | last post by:
Hello world: Background: Yesterday, January 21, Doug Steele was kind enough to help me out on a Left Join problem. I was trying to return all stores and their Gross Adds for December, 2004...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
42
by: PC Datasheet | last post by:
I have zero experience with using a SQL database for a backend and Access for a frontend. I have some questions: 1. Does an SQL database have tables? 2. How does Access connect to the data in...
0
by: dba123 | last post by:
THERE HAS TO BE A SOLUTION FOR THIS!!!! How can I get around the limitation in SSRS 2005 of being able to SUM a Group referenced field in my FOOTER!!! It's driving me nuts My footer field's...
4
by: Max2006 | last post by:
Hi, I am developing a web application on windows XP. A page within my application needs to access to SSRS running on the same machine. Once the web application tries to consume the SSRS web...
5
by: JohnDriver | last post by:
Hi, I am having a form which has a text box and 3 radio buttons. I am using GET method in Ajax to pass the value. I can pass the value of the textbox fine but how to pass the value of radio...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.