|
-
Feb 21st, 2005, 04:18 PM
#1
Re: Getting RecordCount
How do I refer to the Count() field in my RS ? I forgot that I had already done it with the complex query. Now I need it for the simple query. If I can add the count like szlammy said, I'd like to do that.
EDIT: I have this
VB Code:
rs.Open "Delete TempTable .* from TempTable ", cn, adOpenKeyset, adLockOptimistic, adCmdText
rs.Open "INSERT INTO TempTable (RecCount) " & _
"SELECT Count(*)" & _
"From FarmingTemp", cn, adOpenKeyset, adLockOptimistic, adCmdText
RecCount = rs.Fields(1)
So how do I get it back out. I've also tried RecCount = rs.fields("RecCount") but that returns an error.
Last edited by dglienna; Feb 21st, 2005 at 04:37 PM.
-
Feb 21st, 2005, 04:41 PM
#2
Re: Getting RecordCount
I think I figured it out:
VB Code:
rs.Open "select RecCount from TempTable", cn, adOpenKeyset, adLockOptimistic, adCmdText
RecCount = rs.Fields("RecCount")
-
Feb 21st, 2005, 05:14 PM
#3
Re: Getting RecordCount
Still like to know how to use the example that slammy suggested.
-
Feb 21st, 2005, 05:16 PM
#4
Re: Getting RecordCount
 Originally Posted by dglienna
Still like to know how to use the example that slammy suggested.
I am not familiar with the WORD object you are using - it appears that you don't have access to the RS from the code you posted...
Where is the execute or open of the recordset?
-
Feb 21st, 2005, 05:35 PM
#5
Re: Getting RecordCount
word takes care of it all.
it I do a separate query, how do I access the count()? Where is it placed?
The only way I could get a count is my later code that placed it into a seperate field in a new table. If I use it like you did? How do I retrieve it?
I think that I see that you are putting it into an extra field in the table? I'm not sure, though.
-
Feb 21st, 2005, 05:37 PM
#6
Re: Getting RecordCount
Code:
rs.Open "SELECT Count(*) From FarmingTemp" _
, cn, adOpenKeyset, adLockOptimistic, adCmdText
RecCount = rs.Fields(0)
OR
Code:
rs.Open "SELECT Count(*) "RecCount" From FarmingTemp" _
, cn, adOpenKeyset, adLockOptimistic, adCmdText
RecCount = rs.Fields("RecCount")
-
Feb 21st, 2005, 05:38 PM
#7
Re: Getting RecordCount
No, I meant from THIS CODE:
VB Code:
Select [First Name], [Last Name], [Mailing Address], City, State, Zip
,(Select Count(*) From [My Temp]) From [MyTemp]
-
Feb 21st, 2005, 05:39 PM
#8
Re: Getting RecordCount
Actually - I didn't mean to leave the FROM as FARMINGTEMP - the FROM should be the real table you are getting this data from.
There is no need for a temporary table in this example.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|