Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


adodc and a datagrid control

Posted on 2002-06-12
Medium Priority
Last Modified: 2012-05-04
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..
Question by:TheScottishMonk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 7072871
try dbgGrid.Text

Author Comment

ID: 7072872
I tried that it will only read the oldvalue, as in my ex '17'
LVL 43

Expert Comment

ID: 7072920
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

Author Comment

ID: 7072949
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."

Accepted Solution

trkcorp earned 200 total points
ID: 7073545
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question