|
-
Oct 16th, 2006, 10:52 PM
#1
Thread Starter
Addicted Member
Sheridan Data Widgits 3 help please
I need some help on the SSDBGrid from Sheridan (no longer around) doing something simple and am missing something obvious. I am basically trying to get a running balance of numbers. The number for each row is in Col(10) and I want to have a running balance calculated and placed in Col(8) of that row, then move to the next. My problem in the code below is the line where I am trying to set the new value to the cell. The CellValue is a read only and their help files says to set a value you use the Value property. However, using the .Value property is not moving along with the rows as I move down, thus resulting in the Col(8) being set is always the first row, not each row as I work down.
I know I am just missing something simple. Please help
Mickey
VB Code:
'Make sure the accumulator is empty
GLRunningBal = 0
LedgerGrid.Redraw = False 'Turn off so don't see movement
'Get current bookmark & first row to be able to return to same relative position
CurrentBkMark = LedgerGrid.Bookmark
CurrentVisableRow = LedgerGrid.FirstRow
LedgerGrid.MoveFirst
'Cycle thru all the rows
For X = 0 To LedgerGrid.Rows - 1
BkMrk = LedgerGrid.GetBookmark(X)
'Calculate the running balance column (col(8)) which is the number in col(10) of this row
'plus what the balance is up to this point
GLRunningBal = GLRunningBal + Val(LedgerGrid.Columns(10).CellValue(BkMrk))
'Here is the problem line
LedgerGrid.Columns(8).CellValue(BkMrk) = GLRunningBal
Next
'Return to original row & relative position
LedgerGrid.FirstRow = CurrentVisableRow
LedgerGrid.Bookmark = CurrentBkMark
LedgerGrid.Redraw = True 'Turn back on
-
Oct 17th, 2006, 03:55 AM
#2
Re: Sheridan Data Widgits 3 help please
you specify the column to be 8, but not specifying the row at all
is this valid
VB Code:
LedgerGrid.cells(x,8).CellValue(BkMrk) = GLRunningBal
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 17th, 2006, 09:19 AM
#3
Thread Starter
Addicted Member
Re: Sheridan Data Widgits 3 help please
By getting the bookmark first and then references it, that references you to that row. Just like the line above where it gets a value out of that row with:
Val(LedgerGrid.Columns(10).CellValue(BkMrk))
There is no .Cells, etc. The line above is right and works, I just can't seem to get it to set a value, only read one.
Mickey
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
|