Hi
I have a dataGrid control populated by way of an ado control. I have set arguments as shown to enable read / write access. I now want to validate grid cell data before it updates the field data in the underlying ado / access database. I have tried many permutations of using the 'click' 'change' and 'validate' options of the Datagrid control to trap the automatic update which would otherwise occur - but have failed!.
For example one data bound table field stores [RewardsPoints]and I wish to set a range check of >=0 and <=1000. Intuitively I would validate data using following syntax which returns an error. Would then check say Column(1) for numeric data etc etc
Would appreciate help on this.
many thanks in anticipation.
For info:
Also, data Grid AllowAddnew, AllowUpdate, Allowupdates all set to true - since this is a requirement.
Part Code only:
I have a dataGrid control populated by way of an ado control. I have set arguments as shown to enable read / write access. I now want to validate grid cell data before it updates the field data in the underlying ado / access database. I have tried many permutations of using the 'click' 'change' and 'validate' options of the Datagrid control to trap the automatic update which would otherwise occur - but have failed!.
For example one data bound table field stores [RewardsPoints]and I wish to set a range check of >=0 and <=1000. Intuitively I would validate data using following syntax which returns an error. Would then check say Column(1) for numeric data etc etc
Code:
If DataGridRewards.Columns(0).CellValue <= 0 Or DataGridRewards.Columns(0).CellValue >= 1000 Then
'Prevent update from ocurring - msgbox advice to user
End If
Would appreciate help on this.
many thanks in anticipation.
For info:
Also, data Grid AllowAddnew, AllowUpdate, Allowupdates all set to true - since this is a requirement.
Part Code only:
Code:
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source= " & "C:\temp\rewardsdatabase.mdb" & " ;Persist Security Info = false"
conn.Open
'Build an SQL string to select all the rewards currently in the file (tblRewards)
strSQL = "SELECT * FROM tblRewards"
adoPoints.Open (strSQL), conn, adOpenStatic, adLockOptimistic
Set DataGridRewards.DataSource = adoPoints
DataGridRewards.Refresh