Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Validate DataGrid cells?

Status
Not open for further replies.

kellyputty

Technical User
Jul 28, 2005
29
0
0
US
I am displaying records using a data grid from VB6. I allow the user to edit individual entries.

I would like to add user error control so that:

Record:
Field1: Account
Field2: Balance
Field3: MinBalance

If the user wanted to edit the Balance but put in an amount lower than the the MinBalance. I could display an error message, however, I don't know how to access the individual fields for validation in a DataGrid.

Thanks in advance,
KellyPutty
 
Rather than using a Datagrid control, you might consider using a Flexgrid control with overlaid textboxes etc. You will have many more options and full control that way. Have a look at faq222-3262 for more details.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Actually the best scenario is the still use the current DataGrid and add data validation to your backend table. If you are using MS Access, then specify a Validation rule on the table level such as: ValidationRule:MinBalance > Balance ValidationText:MinBalance must be greater than Balance.

Right-click the table in design view, click properties then in the property pages type in your validation rule and validation text.

With no coding in the front end app, you get an error message passed on from Access that you violated the validation rule. Until the value meets the rule you are not able to process other rows in the datagrid. You can press esc twice to revert to the original value in the cell you were editing.
 
Oops, got it the wrong way. ValidationRule should be Balance > MinBalance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top