473,480 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

call stored procedure from ms access

I have written a stored procedure (sp) that calculates the number of
seats remaining for an event. I need to pass the event id to the sp.
I have a combo box that lists all the events. When I choose the event
from the combo box the event executes the sp and the 'Enter Parameter
Value' box appears. How can I execute this sp and pass the value to
it via vba and ms access and not have the input box appear?
Also, how do return the value from this sp to a form?
Any help is appreciated.
Thanks.
Nov 13 '05 #1
3 8995
You said "the enter value parameter box appears" suggesting somewhere in
what you are doing there is a parameter query. If i understand your
question correctly you could replace the predicate in the parameter query
with a reference to the combo box that you mention.

eg. in you query make the predicate forms!formname!controlname where
"formname" is the name of the form you are working on and "controlname" is
the name of the combo box.

"kevin" <di*****@comcast.net> wrote in message
news:c4**************************@posting.google.c om...
I have written a stored procedure (sp) that calculates the number of
seats remaining for an event. I need to pass the event id to the sp.
I have a combo box that lists all the events. When I choose the event
from the combo box the event executes the sp and the 'Enter Parameter
Value' box appears. How can I execute this sp and pass the value to
it via vba and ms access and not have the input box appear?
Also, how do return the value from this sp to a form?
Any help is appreciated.
Thanks.

Nov 13 '05 #2
Tony,Thanks for the reply.
Here is my existing sp code...
--------------------------------------------------------
ALTER PROCEDURE sp_SpotsRemaining2
(
@EventID int
)
AS
/* -- get maxsignup number
-- get total number of people signed up for specific event*/

declare @MaxSignup int
declare @EventCountStaff int
declare @EventCountStudent int
declare @EventCountNonStudent int
declare @SpotsRemaining int
declare @EventCount int
declare @EventCountTotal int

Set @EventCountStaff = 0
Set @EventCountStudent = 0
Set @EventCountNonStudent = 0

--get max number available for event
Set @MaxSignup = (SELECT dbo.Spess_tblCreateNewEvent.MaxSignup FROM
dbo.Spess_tblCreateNewEvent where
dbo.Spess_tblCreateNewEvent.EventID = @EventID)
--get number of spots remaining for all three categories
(Staff,Students,Non-Students)
Set @EventCountStaff = (Select count(*) FROM
dbo.Spess_tblEventSignup_Staff where
dbo.Spess_tblEventSignup_Staff.stfEventID = @EventID)

Set @EventCountStudent = (Select count(*) FROM
dbo.Spess_tblEventSignUp_Student where
dbo.Spess_tblEventSignUp_Student.EventID = @EventID)

Set @EventCountNonStudent = (Select count(*) FROM
dbo.Spess_tblEventSignup_NonStudent where
dbo.Spess_tblEventSignup_NonStudent.nonEventID = @EventID)
--calculate number of total spots filled
Set @EventCountTotal = @EventCountStaff + @EventCountStudent +
@EventCountNonStudent
--calculate number of spots remaining
Set @SpotsRemaining = @MaxSignup - @EventCountTotal
SELECT @SpotsRemaining

RETURN

------------------------------------------
If I understand correctly do I replace @EventID with
forms!formname!controlname?
Your example: forms!formname!controlname
becomes: forms!frmEventSignup!cmbstfEventID

Do I need to include a @ with my new predicate, can you insert the
correct code in the sp for me to show me how it should look. Also do you
know how to return the value from the sp into a form.
Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The RowSource of the ComboBox should be like this:

EXEC sp_SpotsRemaining2 Forms!frmEventSignup!cmbstfEventID

The control "cmbstfEventID" should not be the name of the ComboBox that
is calling the SP.

If the ComboBox is on the form "frmEventSignup" then you can shorten the
call to this:

EXEC sp_SpotsRemaining2 Form!cmbstfEventID

Here, "Form" means the current form.

Another version of the same call is:

EXEC sp_SpotsRemaining2 @EventID=Form!cmbstfEventID

You can get rid of the RETURN statement in the SP. Since it is the last
statement in the SP it isn't actually needed.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQVG9/oechKqOuFEgEQIvlACgwwe4Ds9cbW1D8CFl80ZoSWx439UAoMw u
OGxpKpae6cg0SIsyU03SlC6o
=y1Ci
-----END PGP SIGNATURE-----
Kevin Dickie wrote:
Tony,Thanks for the reply.
Here is my existing sp code...
--------------------------------------------------------
ALTER PROCEDURE sp_SpotsRemaining2
(
@EventID int
)
AS
/* -- get maxsignup number
-- get total number of people signed up for specific event*/

declare @MaxSignup int
declare @EventCountStaff int
declare @EventCountStudent int
declare @EventCountNonStudent int
declare @SpotsRemaining int
declare @EventCount int
declare @EventCountTotal int

Set @EventCountStaff = 0
Set @EventCountStudent = 0
Set @EventCountNonStudent = 0

--get max number available for event
Set @MaxSignup = (SELECT dbo.Spess_tblCreateNewEvent.MaxSignup FROM
dbo.Spess_tblCreateNewEvent where
dbo.Spess_tblCreateNewEvent.EventID = @EventID)
--get number of spots remaining for all three categories
(Staff,Students,Non-Students)
Set @EventCountStaff = (Select count(*) FROM
dbo.Spess_tblEventSignup_Staff where
dbo.Spess_tblEventSignup_Staff.stfEventID = @EventID)

Set @EventCountStudent = (Select count(*) FROM
dbo.Spess_tblEventSignUp_Student where
dbo.Spess_tblEventSignUp_Student.EventID = @EventID)

Set @EventCountNonStudent = (Select count(*) FROM
dbo.Spess_tblEventSignup_NonStudent where
dbo.Spess_tblEventSignup_NonStudent.nonEventID = @EventID)
--calculate number of total spots filled
Set @EventCountTotal = @EventCountStaff + @EventCountStudent +
@EventCountNonStudent
--calculate number of spots remaining
Set @SpotsRemaining = @MaxSignup - @EventCountTotal
SELECT @SpotsRemaining

RETURN

------------------------------------------
If I understand correctly do I replace @EventID with
forms!formname!controlname?
Your example: forms!formname!controlname
becomes: forms!frmEventSignup!cmbstfEventID

Do I need to include a @ with my new predicate, can you insert the
correct code in the sp for me to show me how it should look. Also do you
know how to return the value from the sp into a form.
Thanks.


Nov 13 '05 #4

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

Similar topics

0
6678
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
3
23967
by: Mariusz | last post by:
I want to write function to call another function which name is parameter to first function. Other parameters should be passed to called function. If I call it function('f1',10) it should call...
3
7929
by: Chris | last post by:
Hello everyone I want to call a DB2 7.2 stored procedure via ADO in VC++ 7.1 It has 4 parameters, the 1st and the 4th are OUTPUT and the others are INPUT params. My code looks like this:...
4
3223
by: Jean-Marc Blaise | last post by:
Dear all, I have simulated the windows MULTI application with a java program calling the SQLTP1DL proc referenced as DB2DARI application, on Linux Intel or ZLinux. If the proc is NOT FENCED,...
5
3761
by: Amaryllis | last post by:
I'm trying to call a CL which is located on our AS400 from a Windows application. I've tried to code it in different ways, but I seem to get the same error every time. Does anyone have any clue...
3
15749
by: mandible | last post by:
I'm trying to call one stored procedure inside another. I was wondering if this is possible Some ideas I was toying with is putting the first stored procedure inside of a temp table but haven't...
5
1775
by: Pedro Vera | last post by:
I am helping somebody setup one of the asp.net starter kits. I converted it from sql express to sql server with no real issues, and I got it running local perfectly. On my first attempt to run...
2
10502
by: savio XCIX | last post by:
I created the following stored procedure: ======= CREATE PROCEDURE TBLNAME.proc_test (IN p_custnum VARCHAR(8), IN p_zipcode...
2
4062
by: acw | last post by:
On a SQL Server 2000 db I would like to setup a stored procedure that accesses couple tables and runs the extended stored procedure xp..cmdshell. The goal is to grant users with limited privileges...
12
30897
by: barmatt80 | last post by:
I don't know if this is the right part of the forum. But.... I have been working all night trying to create a web service to call a stored procedure in sql server 2008. The stored procedure calls...
0
7048
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
6911
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
7050
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,...
1
6743
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
5344
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,...
1
4787
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...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
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...
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.