Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

dbgrid

Posted on 2000-08-23
6
Medium Priority
?
446 Views
Last Modified: 2012-06-27
how i can make a validation by field_level within the dbgrid , on another way how i can check a text that i input it in a column if it is correct or not and if it's not i want to prevent the curssor from the moving to another cell(by press the return key) untel input a correct data
0
Comment
Question by:nadernabil
[X]
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
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:marcgale
ID: 4044467
I would check that the text is valid and then return the cursor to the cell (and blank it out, if necessary) if the check determined the text to be invalid.
0
 
LVL 2

Expert Comment

by:Sidneym
ID: 4047711
Check out the event:

DBGrid1_BeforeColUpdate

In this event , you can validate the new value, track the old value, and cancell the update if your validation requires it !!

hope this would help!!
0
 

Accepted Solution

by:
gkakas earned 300 total points
ID: 4049191
The event
BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)

is triggered just before data is accepted by the grid and then the focus moves to somewhere else.

The parameter ColIndex is the id of the column in the Columns collection and indicates the field being edited.

Parameter OldValue is obviously the previous value of the cell and Cancel is a boolean variable that can be set to true in order to prevent the grid from accepting the value entered by the user and moving to next cell or somewhere else.

Now this is how you get the value that the user entered:

Dim Text as string

Text = dbgrid1.Columns(ColIndex).Text


(If you need info about the current row you can use the rowbookmark dbgrid1.RowBookmark(dbgrid1.Row) in any way you like.)

Finaly you have to do your validation:
select case colindex
   case constMyValidationColumnID
        if not text like sMypattern then cancel=true
   case else
end select
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Sidneym
ID: 4049277
Hey gkakas ,

I thought that was what i just suggested.
0
 

Expert Comment

by:gkakas
ID: 4049406
Dear Sidneym,

Sorry if it is so, I am new here and saw no info about getting current value and I think it is not obvious that you have to read the grid text to get it, although it is necessary for the validation of data.

But if you still feel I should withdraw the answer send an email to gkakas@otenet.gr  and I will do it immediatelly.

Yours sincerelly George Kakaletris
0
 
LVL 2

Expert Comment

by:Sidneym
ID: 4061841
gkakas ,

no need , its ok ..after all the goal is to give advice to those who need it.

Cheers!
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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

636 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