By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 2,140 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

How to retrieve record value from Recordset ?

P: 1
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
Share this Question
Share on Google+
2 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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
Expert Mod 15k+
P: 31,186
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

Post your reply

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