473,804 Members | 3,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.dl l" _
Alias "ShellExecu teA" _
(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_ME M = 0&
Private Const ERROR_FILE_NOT_ FOUND = 2&
Private Const ERROR_PATH_NOT_ FOUND = 3&
Private Const ERROR_BAD_FORMA T = 11&

Sub RunReport()
Dim url As String, lRet As Long
url =
"http://yourServer/ReportServer?/rptDir/reportName&rs:F ormat=excel&Rec or
dID=10007&UserI D=steve"

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

after ...rs:Format=ex cel... 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 3027
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.c om
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:F ormat=excel&Rec or
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.c om
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&Re cordid=" _
& 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=exce l&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.c om
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.c om
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 7 '08 #7
"simpleton via AccessMonster.c om" <u45284@uwewrot e in message
news:8850d1ba82 a79@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.c om
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.c om
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
23978
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 want to pass a parameter to the GameFactory constructor like this instance = (GameFactory)(Class.forName(name).newInstance(field) ); Here I pass parameter field which is an int but when I do so I get compile
5
13224
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 report vba instead of making different queries. Here's my query sql: UPDATE Draw SET Draw.Billed = Yes WHERE (((Draw.Billed)=No) AND ((Draw.WholesalerName)="Hudson"));
9
3212
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 (even though some of them had no Gross Adds for that month). My query would only show the non-zero GA stores. Doug stated "It's because of the Where clause. The stores which don't have any records for the period in question are being eliminated...
7
21643
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 server ? Is it possible to use parameters in pass-through queries ? An additional question: Is it possible to connect to a database on MySQL or PostgreSQL using ADO ? Is it possible to execute pass-through queries with parameters, using ADO...
42
5657
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 an SQL database? Linking, importing, or ??? 3. Earlier today there was a thread regarding DAO and ADO. In the thread it was said that ADO is very useful when the backend is a SQL database. Could someone explain that?
0
6233
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 expression (where the problem lies): =SUM(Fields!GrossGoal1.Value, "CustomerNumber_Grp") The GrossGoal1 group field that I'm trying to reference right above it in the same table column has: =((Fields!FeeGoal.Value) / Fields!FeeSchedule.Value)...
4
2808
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 services, I receive the following error: System.Web.Services.Protocols.SoapException: The permissions granted to user DEV1\ASPNET' are insufficient for performing this operation. --->...
5
14013
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 button? I searched a few things on Google but I find the javascript below most useful in my case but there is some problem that my code is not running: var test = document.getElementsByName("meal"); for (i = 0; i < test.length; i++) {
12
11117
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. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10558
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.