473,568 Members | 2,962 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sample Stored Procedures (ADP)

6 New Member
Does anyone know of a good place to get a couple of sample stored procedures for a .adp project in Access? Or maybe someone can just help with this question....

I know how to pull data out for single table:
ALTER PROCEDURE ArchiveLog
AS SELECT PROD_NAME, ARCHIVE_TS
ORDER BY PROD_NAME

but I need to make a query where, to simplify the problem, I've got the tables
DM_LABEL
L_DATA
V_DATA
PRODUCT
SG_DATA
and others
I need to get the VALUE column from V_DATA if the LABEL_ID = the LABEL_ID from L_DATA and if the NAME in L_DATA is = "Operator" and so on and so forth.

The database that I"m accessing is basically just a maze of these little tables that need to be accessed multiple times in order to get info like Lot number, Operator, Audit time, etc. The same thing needs to be repeated for values in other tables based on being linked to that particular audit.

The whole thing needs to be run based on a parameter provided by the user, so they could say that they only wanted products with part number 587 and lot number 32.

I'd love a shove in the right direction.
Sep 7 '07 #1
3 3570
Jim Doherty
897 Recognized Expert Contributor
Does anyone know of a good place to get a couple of sample stored procedures for a .adp project in Access? Or maybe someone can just help with this question....

I know how to pull data out for single table:
ALTER PROCEDURE ArchiveLog
AS SELECT PROD_NAME, ARCHIVE_TS
ORDER BY PROD_NAME

but I need to make a query where, to simplify the problem, I've got the tables
DM_LABEL
L_DATA
V_DATA
PRODUCT
SG_DATA
and others
I need to get the VALUE column from V_DATA if the LABEL_ID = the LABEL_ID from L_DATA and if the NAME in L_DATA is = "Operator" and so on and so forth.

The database that I"m accessing is basically just a maze of these little tables that need to be accessed multiple times in order to get info like Lot number, Operator, Audit time, etc. The same thing needs to be repeated for values in other tables based on being linked to that particular audit.

The whole thing needs to be run based on a parameter provided by the user, so they could say that they only wanted products with part number 587 and lot number 32.

I'd love a shove in the right direction.

Nice to see you working on Stored procedures Christina....

What I am going to relate to you now concerns bound forms ok? that is to say where your strategy is to bind the form to a recordsource and let access do the work navigating records and so on rather than you controlling it via ADO recordsets in code. Its the easiest to start with, without having to understand the syntax for ADO coding as well......infor mation overload.... you can always do that later once you get the form interaction methodology of using an ADP form with a stored procedure.

Stored procedures accept parameters and the body of the procedure itself accepts the value of the parameter passed to it and responds accordingly a simple example of this is can be a basic select:

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE dbo.usp_ GetMyLabel
  2. (@label varchar(100))     -- <<<<<<this is the parameter passed in with datatype defined
  3. AS   --<<<< this AS word is part of the procedure
  4. -- and then the select statement using the parameter as part of the WHERE clause
  5. SELECT [VALUE] FROM vdata where [VALUE]=@label
  6.  
  7. GO
This returns to you a dataset ie a one column one row ([Value])
containing the values '12345' pre-supposing of course the table has the data.

So how did you 'pass' the parameter to the stored procedure from within your access form?.

Well lets say your form was purpose built to 'always' require that value as a dataset. The value would be passed as part of the FORMS InputParameters property (you see this by selecting View properties for the form its at the bottom of the dialog list.)

When the form opens it looks for its record source which, in this case would be the name of the stored procedure itself. It in turn looks to the inputparameter box if you like for the parameter.

Tip: (a must have) always use the 'owner' prefix (dbo) when using stored procedures or any view from an Access ADP this is very relevant if in a multi users environment particularly where users can create their own objects on the server from the client side.

So then the recordsource for the form as I said would be dbo.usp_GetMyLa bel. The PARAMETERS for this stored procedure are typed into the InputParameters like this @label='12345'

All very well and good but not a good example, maybe so, but it is the barest in order to quickly understand the principle because from here you then build on that like so:

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE dbo.usp_ GetMyLabel
  2.  (@namebeingpassedin-- <<<<<<this time the parameter passed in is variable parameter seeking name as you required
  3. AS   --<<<< this AS word is part of the procedure
  4. -- and here is the SQL statement
  5. SELECT  TOP 100 PERCENT [VALUE] as MyValue FROM dbo.vdata
  6. INNER JOIN dbo.L_DATA on dbo.vdata.LABEL_ID=dbo.L_DATA.LABEL_ID
  7. WHERE [NAME]=@namebeingpassedin
  8. ORDER BY v.data.[VALUE]
  9. GO

(Notice in the above syntax how I have changed the NAME value of the field to alias it as MyValue. Watch out for using reserved words and so on for field naming etc)

The above stored procedure (sproc as they become known) answers basically this bit of your question

I need to get the VALUE column from V_DATA if the LABEL_ID = the LABEL_ID from L_DATA and if the NAME in L_DATA is = "Operator"

Q) So how did the actual word 'Operator' get passed to the procedure?
A) It was passed in as a variable via the inputparameters section of the form properties

Q) How did we get the form to do this?
A) Create a continuous form with one textbox on it set the forms recordsource to dbo.usp_GetMyLa bel. In Form design view type into the InputParameters property for the form this

@namebeingpasse din=[Enter the name to pass in]

This will bring you up a dialog prompt box (When you reopen the form) where you can physically type 'Operator' in alternatively you could use this

@namebeingpasse din=Forms!MyFor mName!MyListbox

where the parameter value would then being sought on open from a listbox value mounted on your form if you wanted to do it that way, or it could be a textbox or option group value and so on.

So in short.... you do not need a mirad of stored procedures to achieve everything you want to achieve (my advice is to resist creating too many stored procedures where the only difference is a change in criteria) just identify the tables you wish to work with and create the SQL syntax to suit the circumstances passing into the stored procedure the WHERE clause argument value which on execution of the SQL will return the prescribed dataset to your form

I hope this helps you

Jim
Sep 7 '07 #2
ChristinaB
6 New Member
Ok. I think I've got a lot to chew on for a while. Thanks, Jim!
Sep 10 '07 #3
Jim Doherty
897 Recognized Expert Contributor
Ok. I think I've got a lot to chew on for a while. Thanks, Jim!
As a PS I am on vacation as of today (off to sunny cyprus) so if you don't get a resolution you can PM me and I'll continue on return next week?

Jim
Sep 11 '07 #4

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

Similar topics

6
2315
by: Wim van Rosmalen | last post by:
I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have to deal with more sophisticated queries (may I call them so?) like stored procedures. I have a form with a combobox for selections and a textbox to enter a certain value. Let us say I call the combobox @select and the textbox @find. The combobox always shows the first of...
1
2081
by: zlatko | last post by:
I use a stored procedure that is calling several other stored procedure which update or append values in several tables. All of them are stored procedures with input parameters by which they filter rows to be updated or inserted into other tables. Filtration is based on certain actual values on forms (form with several subforms). My...
3
2464
by: Ryan.Chowdhury | last post by:
This is a general question regarding the use of view and stored procedures. I'm fairly new to databases and SQL. I've created a SQL database using an Access Data Project ("ADP") and I'm satified with the table structure. I've moved on to building some front ends for our users. I'm running into situations where I want subreports to be...
3
6175
by: Lauren Quantrell | last post by:
I am feeling a little overwhelmed trying to get my MDB-ADP conversion going. The first thing I need to figure out (very quickly) is how to use the values of unbound controls of forms in Stored Procedures. For example, I have a form with the unbound controls startDate and endDate. When users click buttons, the dates change and a subform is...
1
1504
by: thom | last post by:
Thanks in anticipation... I have an .adp where I connect to an MSDE sql backend. A number of networked PC's connect to this MSDE datasource. All PC's can see and connect to the sql service. However, when I open the .adp, a number of the computers rename all the stored procedures (Office 2000) with an ";1" suffix i.e. Storedproc;1 - some...
1
1659
by: rdshultz | last post by:
Good morning everyone. Could someone tell me if there is a book out there which gives examples of both VB.net code and creating SQL Server 2000 stored procedures and how you get them to work together in the most efficient way. Right now we have a server at our Philadelphia office and I am in our St. Louis office we are connected with a T1...
3
1390
by: Ed Pinnegar | last post by:
I've looked everywhere for info on stored procedures using Access. Any info on how to make one? Thanks! Ed
5
3463
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored Procedures. I thought stored pricedures were an Oracle/MS SQL Server thing and don't know how they work with Access Jet. I've looked at some of...
3
1576
by: Darkside12 | last post by:
Hi, I'm trying to build a dynamic query by form. The idea is that a user can select a table in the database via a combo box and this will then change all of the text box labels on the form to match the field headers for the selected table. It also hides any text boxes that are surplus to the number of fields of the selected table. The user...
0
7693
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...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
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. ...
1
7665
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...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.