Data Validation with ADO and Data Grid 
Author Message
 Data Validation with ADO and Data Grid

I am new to VB and trying to use the Data Grid instead of
unbound controls.   I want to validate a record before
writing it to the SQL Server database.  All books I have
read say to put validation code in the ADO
WillChangeRecord event. I have tried to use the the
following code:

Sub adoPrimaryRS_WillChangeRecord(ByVal adReason As
ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As
ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Dim x As Variant
  For Each x In pRecordset.Fields
    Debug.Print x.Name
    Debug.Print x.OriginalValue
    Debug.Print x.Value
    Debug.Print x.UnderlyingValue
  Next

I always get the OriginalValue, the Value, and the
Underlying Value equal to the original data.  I can't get
the new value (x.value) in the datagrid until after this
event has completed.  At that time it is too late to stop
the update with adStatus = adStatusCancel.

Can anyone tell me how to get the new data in the record
before it gets written to the recordset.

I've also tried the WillChangeField event with the same
problem.

Thanks
Bob



Sat, 14 Aug 2004 03:29:05 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. First Cell Empty in Data Grid bound to ADO Data Control

2. ADO Data Control and Data Grid

3. Binary Data in SQL 2000/Conver to Bitmap Data For Data Grid View

4. ADO DATA VALIDATIONS

5. ADO data control 6.0 and ADO data object 2.1 conflict

6. Data Grids and Data Sets

7. Data grid and data binding with a collection

8. Warping Data on Data Grid?

9. Data Wrap on Data Grid?

10. Data Grid For DAO Data Control?

11. ADO Data Grid Control Question

12. VB ADO Data Grid column formatting

 

 
Powered by phpBB® Forum Software