473,394 Members | 1,841 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,394 software developers and data experts.

passing parameters to stored procedure from report

Bob
I'm new to Access projects and SQL server and am not a veteran VB
programmer. There's a cry for help! I'm attempting to print the
current form on screen by using a command button which the user clicks
once they have selected the desired record. The button calls a report
which uses a stored procedure as its record source. The SP has 2 input
parameters, one of which is a datetime data type. In the input
parameters data field of the report I'm referencing the actual form
text boxes as such:

@mrnum nvarchar(12)=[forms]![frm-clt_visit_edit]![MRN],
@visitdate datetime=[forms]![frm-clt_visit_edit]![visit_date]

Here is the stored procedure code:
ALTER PROCEDURE dbo.SP_lookup_visit_rec
(@mrnum nvarchar(12), @visitdate datetime)
AS SELECT dbo.tbl_clients.*, dbo.tbl_client_visit.*
FROM dbo.tbl_clients INNER JOIN
dbo.tbl_client_visit ON dbo.tbl_clients.MRN =
dbo.tbl_client_visit.MRN
WHERE (dbo.tbl_client_visit.mrn = @mrnum) AND
(dbo.tbl_client_visit.Visit_date = @visitdate);

When I click the command button it displays a blank report. When I
remove the form reference for testing, it prompts for the Visit_date
and I can enter the date from the open form - and it prints the current
form without a problem. I know the field is of datetime and the text
box is text, so I've tried converting it by reading the text box into a
varible and using the Cdate function. I've done a debug.print of the
var and it shows up in the immediate window. All of my efforts thus
far have been fruitless. How do I go about passing this date value
into the Stored procedure? Any help is appreciated.

Following is reference to a previous post here that I found when
searching newsgroups.

----------------------------------------------------------------
*If* you are using the stored procedure as a datasource for a report
you could pass parameters from your form to the SP by using the Report
InputParatmeters property:

Example:
@StartDate =[forms]![forms1]![txtBeginnin*gDate], @EndDate =
[forms]![forms1]![txtEndDate]
Your SP would have to be designed to accept @StartDate and @EndDate as
parameters and using them in a where clause:
Between @StartDate and @EndDate

Nov 13 '05 #1
2 5238
Bob wrote:
I'm new to Access projects and SQL server and am not a veteran VB
programmer. There's a cry for help! I'm attempting to print the
current form on screen by using a command button which the user clicks
once they have selected the desired record. The button calls a report
which uses a stored procedure as its record source. The SP has 2 input
parameters, one of which is a datetime data type.


This is what I do in an ADP

create a public function in a standard module eg

PublicFunctionThatReturnsaStringofInputParameters( ) as String

This function should return a string such as:

@ParameterName int=32, @OtherParamterName varchar(50)='Bizarro' ... etc

set the recordsource of the report to the sproc name: ProcReport

set the input parameters as

= PublicFunctionThatReturnsaStringofInputParameters( )

If you use this you will have to use your own string.

However I have seen a post here that indicates success with

setting the Input Parameters as something like

@ParameterName int=Forms(BlahBlah)!etc, @OtherParamterName
varchar(50)=Forms(YeahYeah)!etc

--
Lyle

To subject an enemy belligerent to an unfair trial, to charge him with
an unrecognized crime, or to vent on him our retributive emotions only
antagonizes the enemy nation and hinders the reconciliation necessary to
a peaceful world.

Justice Frank Murphy
Yamashita v. Styer, 327 U.S. 1 (1946)
Nov 13 '05 #2
Bob wrote:
I'm new to Access projects and SQL server and am not a veteran VB
programmer. There's a cry for help! I'm attempting to print the
current form on screen by using a command button which the user clicks
once they have selected the desired record. The button calls a report
which uses a stored procedure as its record source. The SP has 2 input
parameters, one of which is a datetime data type. In the input
parameters data field of the report I'm referencing the actual form
text boxes as such:


Is your problem with new records? Until a record is committed (saved)
then printing is going to display a blank record. Let's say you have a
command button you may want to enter some code in it like
If Me.Dirty Then Me.Dirty = False
to commit the save prior to printing. IOW, don't print until you've saved.
Nov 13 '05 #3

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

Similar topics

0
by: Aaron | last post by:
The following code works fine when previewing a Crystal report using ASP, EXCEPT when it gets to a report using a SubReport and its associated parameters. The whole report just comes up blank with...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
7
by: rickcheney | last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I had a form where the user entered a value into a text box and when a command button on the form was clicked a Report was...
8
by: Mark Flippin | last post by:
This is for a reporting problem using: Access 2000 SQL Server 2000 Both at SP3 I've a stored procedure in SQL Server 2000 which builds a result set from a disparate set of tables, utilizing...
0
by: Craig Faulkner | last post by:
I have been fighting through my first crystal report in VS2003.NET and have made some headway. Here is what I've done: 1. Created a crystal report in VS2003 from a SQL stored procedure with...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
10
by: Adis | last post by:
Asp.Net Visual Studio 2003 SQL Server. Hi, Obtaining Data Based Upon Multiple Selections From a ListBox... I have database in Sqlserver and ListBox (Multiple Selection Mode) in my Visual...
0
by: Mariana | last post by:
Hello, I am exporting reports in pdf format from .net 2005 . The export is working fine; however the user values of stored procedure parameters does not show in the report. What do I need to do in...
17
by: kkk1979 | last post by:
I have been using access as front end and SQL as Back end. I need help in generating an access report, by using a stored procedure with input parameters as record source. I tried the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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.