Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scroll thru DataGrid Rows

Status
Not open for further replies.

cfcProgrammer

Programmer
Joined
Mar 1, 2006
Messages
88
Location
CA
Hi Folks,

I am trying to read through each row in the datagrid. However, I am staying on the row that is currently highlighted in the grid. ????

Here is the code I have. The actual column in the grid is an expiry date. So, I am checking to see if any or all of the rows have an expiry date... I they all do then I need to display a message BUT if even one of the rows does not have an expiry date(meaning they are still active) then I will not need the message displayed.

Thanks in advance for any help you are able to provide.

CFC

Code:
Dim i As Integer
Dim count As Integer
  
For i = 1 To grdBeneficiaries.ApproxCount
   If (g_AppUtil.GetGridColumnValue(grdBeneficiaries, 4))  <> "" Then
  count = count + 1
  End If
Next

If count = grdBeneficiaries.ApproxCount Then
    MsgBox CONST_MSG_CLOSE, vbExclamation
    Cancel = True
End If
 
Why are you reading through the datagrid instead of its underlying record source?
 
I agree with Bob.

Check at the time you are filling the grid from the datasource.

But as an aside I think I know why your code isnt working.
I dont use the datagrid but the line:

'If (g_AppUtil.GetGridColumnValue(grdBeneficiaries, 4)) <> "" Then' I bet checks the value, as default, of the currently selected row.

You are not including any row index in the above line so it is returning the selected row everytime.

Sound reasonable?

Andy
 
cfcProgrammer,

Did you manage to fix the problem?

I for one would appreciate an update seeing as we spent the time and trouble to reply to your post

Andy
 
Hi Andy,
I apologize for not responding to thank you for your effort. It was truly appreciated.

Here is the final code that I used:
Code:
  Dim i As Integer
  Dim count As Integer
  
  If grdBeneficiaries.ApproxCount > 0 Then
    For i = 0 To (grdBeneficiaries.ApproxCount - 1)
        grdBeneficiaries.Row = i
     If (g_AppUtil.GetGridColumnValue(grdBeneficiaries, 4)) <> "" Then
           count = count + 1
     End If
       Next i
       If count = grdBeneficiaries.ApproxCount Then
         MsgBox CONST_MSG_CLOSE, vbExclamation
         Cancel = True
       End If
  End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top