|
-
Jul 27th, 2003, 11:24 AM
#1
Thread Starter
Member
Problem populating MSFlexGrid *** Resolved ***
I'm writing a program for my department at work and its almost like 2 programs in one. Instead of using a seperate table for each one i'm using a single table and added a LogType field to distinguish between the 2. My problem is that when i try to populate the MSFlexGrid it's just blank. Here's my code, i'm using 2 radio buttons:
VB Code:
Dim intRSCounter As Integer
Select Case Index
Case 0
rsFilter.Open "SELECT * FROM CMELNRN WHERE LogType = 'CMEL'", cnCMELNRN, adOpenStatic, adLockOptimistic, adCmdText
With msgCMELNRN
.Rows = rsFilter.RecordCount + 1
For intRSCounter = 1 To rsFilter.RecordCount
.Row = intRSCounter
.Col = 0
.Text = rsFilter!AnalystName
.Col = 1
.Text = rsFilter!InputDate
.Col = 2
.Text = rsFilter!TimeStarted
.Col = 3
.Text = rsFilter!Comments
.Col = 4
.Text = rsFilter!Event
.Col = 5
.Text = rsFilter!TimeEnded
.Col = 6
.Text = rsFilter!ClosingAnalyst
.Col = 7
.Text = rsFilter!EventStatus
.Col = 8
.Text = rsFilter!Contact
rsFilter.MoveNext
Next intRSCounter
End With
rsFilter.Close
Case 1
rsFilter.Open "SELECT * FROM CMELNRN WHERE LogType = 'NRN'", cnCMELNRN, adOpenStatic, adLockOptimistic, adCmdText
With msgCMELNRN
.Rows = rsFilter.RecordCount + 1
For intRSCounter = 1 To rsFilter.RecordCount
.Row = intRSCounter
.Col = 0
.Text = rsFilter!AnalystName
.Col = 1
.Text = rsFilter!PersonContacted
.Col = 2
.Text = rsFilter!InputDate
.Col = 3
.Text = rsFilter!TimeStarted
.Col = 4
.Text = rsFilter!RequiredContact
.Col = 5
.Text = rsFilter!Comments
.Col = 6
.Text = rsFilter!Issue
rsFilter.MoveNext
Next intRSCounter
End With
rsFilter.Close
End Select
Can anyone tell me why the grid isn't populating and also how i can get it to work? Thanks.
Last edited by IceBreakerG; Jul 27th, 2003 at 02:15 PM.
How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny 
-
Jul 27th, 2003, 11:55 AM
#2
Its pretty hard to tell.
your option button indexes are not 0 or 1.
the RecordCount property is either -1 or 0. What is the CursorType of your recordset?
Just step through the code, check each variable to make sure they contain the values that you expect.
-
Jul 27th, 2003, 12:03 PM
#3
Thread Starter
Member
Ok, i made the code put the recordcount in one of the text boxes when i clicked on the radio button, and it's -1. Question is why is the record count -1 when there are records in the table. The code that i pasted i got from Murach's Visual Basic 6 in capter 8 on page 317, just in case u had that book. I don't think i'm missing anything, i juts substituted the values for what i needed. Problem is the book isn't too clear because of how they have it written. Also why are the indexes for the radio buttons not 0 and 1?
How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny 
-
Jul 27th, 2003, 01:32 PM
#4
A RecordCount property of -1 does not mean there are no records, it means the count is unknown. Only a ClientSide cursor type will return the count accurately. Set this property before opening the recordset.
rsFilter.CursorLocation = adUseClient
You should now get the recordcount properly.
-
Jul 27th, 2003, 02:15 PM
#5
Thread Starter
Member
Great, that worked Thanks alot.
How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny 
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
|