I am using a stored procedure as the recordsource on an MS-Access2000
form:
Forms!frmName.R ecordSource = "dbo.myStoredPr ocedure"
The stored procedure creates a temp table #Contacts and then inserts
matching KeyID values contacts into it. Then I use a union query in
the same stored procedure to create the actual recordset.
What I want to know is how I can return the number of records in the
temp table #Contacts back to MS Access and display it?
I can't just do a VBA recordcount because that will count all the
records returned from the union queries.
What I am doing now feels sloppy, which is to count the records in the
temp table, then display the count (@myCount) in every row of the
recordset, which I display in the header of the form.
Any help is appreciated,
LQ
Example below:
Alter Procedure "myStoredProced ure"
AS
set nocount on
DECLARE @myCount as integer
CREATE TABLE #Contacts (id int identity, ContactID int)
INSERT INTO #Contacts(Conta ctID)
SELECT
Contacts.ID
FROM
Contacts
WHERE
Contacts.LastNa me = 'Jones')
SELECT @myCount = count(*) FROM #Contacts
SELECT
#Contacts.Conta ctID,
NULL as DATA,
@myCount AS CNT
FROM
#Contacts
UNION SELECT
#Contacts.Conta ctID,
Addresses.Addre ssInfo AS DATA,
@myCount AS CNT
FROM
#Contacts LEFT OUTER JOIN
Addresses ON
#Contacts.Conta ctID = Addresses.Conta ctID 2 15438
"Lauren Quantrell" <la************ *@hotmail.com> wrote in message
news:47******** *************** ***@posting.goo gle.com... I am using a stored procedure as the recordsource on an MS-Access2000 form: Forms!frmName.R ecordSource = "dbo.myStoredPr ocedure"
The stored procedure creates a temp table #Contacts and then inserts matching KeyID values contacts into it. Then I use a union query in the same stored procedure to create the actual recordset.
What I want to know is how I can return the number of records in the temp table #Contacts back to MS Access and display it?
Return the value as an output parameter. Instead of binding the form
directly to the procedure, (I guess this is an ADP?), create the recordset
in code with ADO - then you can read the returned parameter and bind the
recordset to the form.
Laren,
=Count(*) in a text control on the form will count the rows in the form.
Doesn't matter what the source of the data is. Also, you can add an aliased
value ("CONTACTS" AS SELECT_SOURCE . . .) to your union query that
identifies which select statement contributed the result. You can then use
DCount to count only those from the select statement that has your contacts.
"Lauren Quantrell" <la************ *@hotmail.com> wrote in message
news:47******** *************** ***@posting.goo gle.com... What I want to know is how I can return the number of records in the temp table #Contacts back to MS Access and display it? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Don Seckler |
last post by:
I have a data entry form called Draw. This form is used to enter data
in the table called Draw. The table has the following fields:
WholesalerID, MagID, IssueID, CopiesDist, and the index is called
DrawIndex. The DrawIndex is a combination autonumber index that uses
the
combination of these three fields WholesalerID, MagID, IssueID to
ensure that each record is unique.
When a used tries to enter data that has a the same WholesalerID,...
|
by: Ryan |
last post by:
I've got a problem I have't run up against before. I generally test
for an empty recordset using BOF and EOF. Today, for the first time I
ran into a problem where my recordset shows BOF and EOF = true despite
the fact that there is has an actual record (record count = 1). The
count is correct, there should be one record (it shows on the form),
but it is not accessible in the recordset. Does anyone know why this
might be? The code is...
|
by: ricky.agrawal |
last post by:
I'm really not sure how to go about this in Access. What I've created
is a table for each location. Those tables are identical in format but
different in information.
The tables are named after key points such as the store number and the
store ID. The fields of those tables are generic fields such as sales
per day, bank deposit and what not. The first field for each store
table is the date and I've set that as the primary key as one...
|
by: polocar |
last post by:
Hi,
I'm writing a program in Visual C# 2005 Professional Edition.
This program connects to a SQL Server 2005 database called
"Generations" (in which there is only one table, called
"Generations"), and it allows the user to add, edit and delete the
various records of the table.
"Generations" table has the following fields:
"IDPerson", NamePerson", "AgePerson" and "IDParent".
A record contains the information about a person (his name, his...
|
by: Catch_22 |
last post by:
Hi,
I have a stored procedure that has to extract the child records for
particular parent records.
The issue is that in some cases I do not want to extract all the child
records only a certain number of them.
Firstly I identify all the parent records that have the requird number
of child records and insert them into the result table.
| |
by: Swinky |
last post by:
I hope someone can help...I feel like I'm walking in the dark without a
flashlight (I'm NOT a programmer but have been called to task to do
some work in Access that is above my head).
I have code that will successfully copy a record and append the
information to a new record in the same table (parent table) within a
form. However, there are related child tables with primary keys (set
to Autonumber) stored in sub-forms. That information...
|
by: john |
last post by:
In my form I have a master table and a details table linked 1xM. I can
search through the whole parent table but I also like to be able to search
through the child table fields to find parent records. Should I design a new
form for this or can I somehow make this work in the same form.
Thanks in advance,
john
|
by: Phil Stanton |
last post by:
I have a form based on a complex query (Lots of tables)
If I delete a record, everything appears to be OK. Get the message "Youa are
about to delete 1 record ....". I say yes. The record count goes down
correctly. Then if I do Records-->Remove Filter/Sort there are the deleted
records back as if they had never been deleted. Same thin exactly if I do
the operation on the form's recordsource query, so that eliminates anything
to do with...
|
by: tekctrl |
last post by:
Environment; Win2K PC with 1Gb of RAM and plenty of HD space running Access
2002
Issue; Access presents a blank data entry form in the Forms view when the
New Record icon is used. However, it won't allow any fields to have data
entered into them. I can edit & save existing records without problem.
When I go into the Tables view, I can add records and data ok and save
without problem. I go back into the Table and I can see the data. ...
|
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...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |