adodc and a datagrid control

I have a dbgrid connected to an adodc. I can't self -errorcheck if the user is adding an incorrect value into the grid. For example I have a integer field called 'Panels' on the grid, now if the user tries to enter a non-numeric field I want to be able to pop up a msgbox saying 'error' and the put the old value back. When I tried to use the 'dbgGrid_BeforeColUpdate' I could only read the oldvalue in the cell, not the one just entered. ex if the old value was '17' and they tried to enter 'bb' I can't pass the value 'bb' into a variable, only 17. It's almost like 'bb' doesn't exist until the adodc enters it into the db. So when the adodc tries to enter the new value into the db it comes up with it's own error message, which I don't want. Please help, thanks in advance..
TheScottishMonkAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
trkcorpConnect With a Mentor Commented:
try BeforeColumnEdit, EX:

Private Sub DBGrid1_BeforeColEdit(ByVal ColIndex As Integer, ByVal KeyAscii As Integer, Cancel As Integer)
Select Case ColIndex
Case 1
   If KeyAscii < 48 Or KeyAscii > 57 Then
      MsgBox Chr$(KeyAscii) & " is not numeric.)"
      Cancel = True
   End If
End Select
End Sub
0
 
bob_onlineCommented:
try dbgGrid.Text
0
 
TheScottishMonkAuthor Commented:
I tried that it will only read the oldvalue, as in my ex '17'
0
 
TimCotteeHead of Software ServicesCommented:
You don't have to put the old value back, just set Cancel = True

Private Sub DBGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)
  If NOT IsNumeric(DBGrid1.Text) Then
    Msgbox "Not a number, cancelling",vbExclamation+vbOKOnly
    Cancel = True
  End If
End Sub
0
 
TheScottishMonkAuthor Commented:
k I tried that.. what happens is DBGrid1.text still has the value of 17, not 'bb'. So it still considers it a numeric value. This is the error that I get when it tries to enter 'bb' into the db, not sure if it will help or not... 'Multiple-step operation generated errors. Check each status value."
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.