473,396 Members | 2,034 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,396 software developers and data experts.

How to pass parameter from text box to stored procedure

Hi,
I have created a command button called Reports in Access 2007 using wizard for generating a report between two dates.The stored procedure behind the button is spr_Reports(SQL server 2008):

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[spr_Reports] 
  2.     @start_date date,@end_date date
  3. AS
  4. BEGIN
  5.     select convert(varchar(20),date,103)as Date,d.Planned,d.Comment 
  6.     from tbl_Calendar e join tbl_Calendar_Details d 
  7.     on e.Calendar_ID=d.Calendar_ID
  8.     where Date between @start_date and @end_date order by Date asc
  9. END
According to this procedure,If I click on Reports button it will prompt for start and end date.Instead of prompting I want to give input to the stored procedure from two text boxes called tboStartDate and tboEndDate.

The code behind the Reports button is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CmdReports_Click()
  2. On Error GoTo Err_CmdReports_Click
  3.  
  4.     Dim stDocName As String
  5.  
  6.     stDocName = "dbo.spr_Reports"
  7.     DoCmd.OpenStoredProcedure stDocName, acViewNormal, acEdit
  8.  
  9. Exit_CmdReports_Click:
  10.     Exit Sub
  11.  
  12. Err_CmdReports_Click:
  13.     MsgBox Err.Description
  14.     Resume Exit_CmdReports_Click
  15.  
  16. End Sub

Can anyone please help me out of this?
Aug 28 '13 #1
3 5963
zmbd
5,501 Expert Mod 4TB
Stored procedures have no way of "seeing" the form's values.

The basic is that you will make a connection to the backend, and then use a pass thru to execute the stored procedure

execute Stored_procedure_Name 'Value1','Value2'

Read thru these two first so that you have a foundation to work from:
ACC: How to Simulate Parameters in an SQL Pass-Through Query

ACC: How to Return Values from SQL Stored Procedures

once you read those, then you should follow this thread...
how to pass values to a calling stored procedure
(really read the MS stuff first, then the Bytes thread, for some reason, once all three are read, it all makes sense - like a puzzle is suddenly assembled)

You might find this helpfull too:

[edit{ok, one more article that I just found:
How to write VBA to SQL Server sub routine that calls a Stored procedure
Aug 28 '13 #2
Hi,
Actually am new to VBA. I know nothing about VBA. In my project all the applications(.adp) are using Access 2007 as front end and SQL server 2008 as back end.In one of the applications it seems stored procedure directly fetched the input from a text box.The code is
Expand|Select|Wrap|Line Numbers
  1. strRowSource = "EXEC dbo.spr_Find_Project_by_Number '" & Me.tboProjectNo & "'"
  2.     Me.lboOutputDatabaseProjects.RowSource = strRowSource
  3.     Me.lboOutputDatabaseProjects.Requery
Can you please make me clear on this?
Aug 29 '13 #3
zmbd
5,501 Expert Mod 4TB
Twinprabu
Post #3 is a different question than what you orginally asked. Please start a new thread. WHen you do, you'll need to provide a tad more information.

(helpful hint: When formating text using the [CODE/] button, select/highlight the section of text first. Then click on the button. The text should then be between one set of the [code] [/code] tags.)
Aug 29 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: SwatSoftwareDev | last post by:
Hi All, I want to use XML technologies with SQL Server 2000 for sending master details data from Application to SQL Server. I'm using xmldocument class for writing data in the form of attribute...
6
by: gurvar | last post by:
hI, i'M TRTYING TO PASS PARAMETER TO A SP.BUT GETTING "OUT OF RANGE ERROR ERROR FOLLOWING IS THE CODE: Dim conDG As SqlClient.SqlConnection Dim cmdDG As SqlClient.SqlCommand Dim drDG As...
3
by: Joseph Lu | last post by:
Hi, all I have a stored procedure created in SQL Server like the following lines. // stored proceudre code starts here CREATE PROCEDURE sp_insertdata @strdata varchar(250) , @rsult BIT...
4
by: jed | last post by:
I have tried sqlCommand1.Parameters.Value = float.Parse(textBox1.Text); but the debugger says that it cant see the parameter How can i gain access to the parameter in C# EXpress.thanks in...
5
by: Dennis | last post by:
Hi I'm trying to alter my stored procedure to take a parameter for the Database Name, but as usual the syntax is killing me. Thanks for any help Dennis ...
1
by: kcosgayon | last post by:
Hello, I have a java program that creates a dynamic SQL statement with where clause. Is it possible to pass the query string (with string where clauses name = 'John") as a parameter in a stored...
3
by: jtrapat1 | last post by:
Im using sql server 2005 and visual studio 2005. I just want to create some reports and deploy them to the local reportserver for an intranet application by using reporting services. I'd like to...
1
by: sreedivya | last post by:
Hi All I am trying to create crystal reports. In this concern i have created a command which execute a stored procedure. This stored procedure takes three parameters which in turn i want to pass it...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: tokcy | last post by:
Hi all, After a long time i am back with a new problem. Right now I am having a problem with stored procedure. I am using stored procedure with PHP/MYSQL. And evry time I am changing the...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.