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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code help with a grid

Status
Not open for further replies.

Tailgun

Technical User
Mar 30, 2002
417
US
I cannot seem to get this to work no matter where I place it in the grid events. I am trying to make sure that those two columns added together don't exceed another column and if it does I want to show a msgbox.

==================
If TDBGrid1.Columns(2).CellText(Bookmark) + TDBGrid1.Columns(3).CellText(Bookmark) > TDBGrid1.Columns(1).CellText(Bookmark) Then
MsgBox "Previously Completed plus Completed cannot exceed Scheduled Value", vbOKOnly, "Quick Manage"
frmAddPayApp.TDBGrid1.SetFocus
End If
================

all the columns are currency. It is a grid with alot of rows and just need to insure no row has those 2 columns exceeding another column's amount in that row.

If anyone has any expertise in Components One Activex Grid 8 I hope they can help.

 
The CellText value is just as it is called: TEXT
Even if the values entered, or comming from the db are numeric.

So you are actually adding:

Cell2 = "1001"
Cell3 = "2002"

Cell2 + Cell3 = "10012002"

If you want to add numeric(currency) values in a grid together use:

CCur(Cell2) + CCur(Cell3) > CCur(Cell1)
 
Thanks for the help LostInCode you got me started in the right direction. Here is what finally worked.
=====================
Private Sub TDBGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)


If (CInt(TDBGrid1.Columns(2).CellText(TDBGrid1.Bookmark)) + CInt(TDBGrid1.Columns(3).CellText(TDBGrid1.Bookmark))) > CInt(TDBGrid1.Columns(1).CellText(TDBGrid1.Bookmark)) Then


MsgBox "Previously Completed plus Completed cannot exceed Scheduled Value", vbOKOnly, "Quick Manage"

Cancel = True


End If

End Sub
=============

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top