473,473 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to retrieve record value from Recordset ?

1 New Member
Hello all,
I'm a newbie in Access vba, so please help...
I have some vba code to count records, but i also need retrieve value from query SELECT SUM (......). There will be only one record (Total SUM)
and cannot find how I can do it..

Here is my vba to count records (maybe it should look similarly..) :

SQLStmt = "SELECT * FROM TEMP_backup;"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQLStmt)
If Not rs.EOF Then
rs.MoveLast
strOrder = rs.RecordCount ' (place records quantity in "strOrder")
End If

Thanks.
Dec 16 '06 #1
2 3917
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hello all,
I'm a newbie in Access vba, so please help...
I have some vba code to count records, but i also need retrieve value from query SELECT SUM (......). There will be only one record (Total SUM)
and cannot find how I can do it..

Here is my vba to count records (maybe it should look similarly..) :

SQLStmt = "SELECT * FROM TEMP_backup;"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQLStmt)
If Not rs.EOF Then
rs.MoveLast
strOrder = rs.RecordCount ' (place records quantity in "strOrder")
End If

Thanks.
I don't understand where or what your query SELECT SUM (......) is so I need more information.

Mary
Dec 16 '06 #2
NeoPa
32,556 Recognized Expert Moderator MVP
Try instead :
Expand|Select|Wrap|Line Numbers
  1. strOrder = Format(DCount("*","TEMP_backup"),"Standard")
Format is your choice but I noticed that the value was returned to a string variable.
This code replaces all of your other code.
Dec 16 '06 #3

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

Similar topics

9
by: Roar | last post by:
Hi! I have got 1 access 2000 DB, one simple search form, and 3 .asp pages (one for deleting a record, one for inserting a record and one for listing searchresults). Deleting records works fine,...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
2
by: Harold | last post by:
Sat I have a customers table with the fields CustomerID and Customer and I use the recordset.addnew method to add a new record to the table. What is the best way to get the CustomerID of the new...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: loreille | last post by:
To insert a record in a Ms Access database and be able to retrieve the newly created ID (autonumber) I used the code below (code 1). Now, the problem is that this is not very secure and that, if...
6
by: kaosyeti | last post by:
hey.... i have a duplicate record issue i could use some help with. on a form that has 2 unbound controls, txtboxyear and cboxmonth, together will automatically fill in an invisible txtboxdate...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
10
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be...
1
maxamis4
by: maxamis4 | last post by:
Hello folks, Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
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...
1
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.