Go Premium for a chance to win a PS4. Enter to Win


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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

824 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