|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
VBA - Rst.recordcount
Hi,
I use openRecordset and then RecordCount but it only seems to be counting the first record. I've used this method before so I can't seem to catch what is going wrong. DETAIL TABLE ========== Customernumberunique - text productID - text OrderNo - text ACTUAL DATA ========== 727490,727490- 1134000000,CAN624576 727490,727490- 0231000000,CAN624576 727490,727490- 0440ME0000,CAN624576 727490,727490- 0276000000,CAN624576 Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM [Detail] WHERE [OrderNo] = 'CAN624576'", dbOpenDynaset)
MsgBox (rst.RecordCount) 'only gets 1 instead of 4
MsgBox (rst("Customernumberunique")) '727490- 1134000000
My understanding was recordcount would have 4, I go to rst.movefirst, then loop through for all records. Am i missing something here? Thanks, |
|
#2
|
||||
|
||||
|
Try,
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM [Detail] WHERE [OrderNo] = 'CAN624576'", dbOpenDynaset)
rst.MoveLast
MsgBox (rst.RecordCount) 'only gets 1 instead of 4
|
|
#3
|
|||
|
|||
|
Is that normal that it needs to actually go through them to count them? I thought a recordset was a copy, so wouldn't it have counted while copying?
btw yes that did get the count ![]() |
|
#4
|
||||
|
||||
|
here's some info regarding RecordCount
Quote:
you can also have a look at VBA Traps: Working with Recordsets
__________________
Come JOIN the party!!! Quote of the Month: Trouble: Luck can't last a lifetime unless you die young. Questions to Ponder: Do cemetery workers prefer the graveyard shift? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 Last edited by mehere : May 9th, 2008 at 09:19 AM. |
|
#5
|
|||
|
|||
|
much appreciated, thanks for the help guys
![]() Ill keep that link just for future reference in case I come across this in distant future and forget lol. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > VBA - Rst.recordcount |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
![]() |
|