|
-
Apr 16th, 2005, 06:45 AM
#1
Thread Starter
Lively Member
RecordCount(resolved)
hi,
i always having problems in using RecordCount. It always give me -1 eventhough there are some records.
below is part of my coding. i want to display the records in a MSFlexGrid. Before the display i check for the recordcount , if the record is > 15 , then the rows will +1. But i always getting the recordcount is -1 even there are many records. Can someone help me to solve this
Private Sub fillDetails()
MSFlexGrid1.Clear
Dim row_counter As Integer
row_counter = 1
With MSFlexGrid1
.FormatString = " No." & "|" & " Date" & "|" & " .............
End With
rs_f.Open "select * from FollowUp where EnqNo = " & Label1 & "", con, adOpenDynamic, adLockPessimistic
If rs_f.RecordCount <> 0 Then
G_RowCheck = rs_f.RecordCount
If rs_f.RecordCount > 15 Then
Me.MSFlexGrid1.Rows = rs_f.RecordCount + 1
Else
Me.MSFlexGrid1.Rows = 15
End If
Last edited by vivian2u; Apr 17th, 2005 at 11:18 AM.
-
Apr 16th, 2005, 07:10 AM
#2
Frenzied Member
Re: RecordCount
 Originally Posted by vivian2u
hi,
i always having problems in using RecordCount. It always give me -1 eventhough there are some records.
below is part of my coding. i want to display the records in a MSFlexGrid. Before the display i check for the recordcount , if the record is > 15 , then the rows will +1. But i always getting the recordcount is -1 even there are many records. Can someone help me to solve this
Private Sub fillDetails()
MSFlexGrid1.Clear
Dim row_counter As Integer
row_counter = 1
With MSFlexGrid1
.FormatString = " No." & "|" & " Date" & "|" & " .............
End With
rs_f.Open "select * from FollowUp where EnqNo = " & Label1 & "", con, adOpenDynamic, adLockPessimistic
If rs_f.RecordCount <> 0 Then
G_RowCheck = rs_f.RecordCount
If rs_f.RecordCount > 15 Then
Me.MSFlexGrid1.Rows = rs_f.RecordCount + 1
Else
Me.MSFlexGrid1.Rows = 15
End If
Replace adOpenDynamic either with adOpenStatic or adOpenKeySet
-
Apr 17th, 2005, 08:04 AM
#3
Re: RecordCount
you may need to move to the end of the recordset to get a correct record count, then movefirst to go back to the start.
rgds
pete
-
Apr 17th, 2005, 08:19 AM
#4
Frenzied Member
Re: RecordCount
 Originally Posted by westconn1
you may need to move to the end of the recordset to get a correct record count, then movefirst to go back to the start.
rgds
pete
not necessary...
-
Apr 17th, 2005, 08:25 AM
#5
Re: RecordCount
it has resolved similar problems for me in the past
pete
-
Apr 17th, 2005, 08:44 AM
#6
Frenzied Member
Re: RecordCount
 Originally Posted by westconn1
it has resolved similar problems for me in the past
pete
yah... i have also seen this working in some conditions..
I think it is provider specific...
I opened a recordset with Access table... and it didn't require me to movelast and movefirst before getting the recordcount..
-
Apr 17th, 2005, 08:47 AM
#7
Re: RecordCount
yeah i know i was using DAO at the time, i don't know if the same would apply to ADO, or even what vivian2u is using.
hence i said "may need"
pete
-
Apr 17th, 2005, 11:17 AM
#8
Thread Starter
Lively Member
Re: RecordCount
Hi guys,
Problem solved when i replace adOpenDynamic either with adOpenStatic or adOpenKeySet. Great !! Cheers !
Vivian2u
-
Apr 22nd, 2005, 02:46 AM
#9
Fanatic Member
Re: RecordCount(resolved)
Hi
I olso confus with opendynamic and open static
any one help to make clear pls, thanks
kamus
-
Apr 22nd, 2005, 02:59 AM
#10
Re: RecordCount(resolved)
Wouldnt this work?
VB Code:
rs_f.CursorLocation=adUseClient
rs_f.Open "select * from FollowUp where EnqNo = " & Label1 & "", con, adOpenDynamic, adLockPessimistic
I believe this would also return the correct recordcount even if its adOpenDynamic....
I olso confus with opendynamic and open static
any one help to make clear pls, thanks
adOpenDynamic: Dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the recordset are allowed, except for bookmarks if the provider doesn't support them.
adOpenKeyset: Keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your recordset. Data changes by other users are still visible.
Last edited by dee-u; Apr 22nd, 2005 at 03:30 AM.
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
|