DbGrid question

DbGrid question

Post by Fred » Sat, 23 Jan 1999 04:00:00

How can we prevent a user to enter more caracter in a dbgrid fields when we
put a max of five in my database.

Because now when a user enter more than fives it gives no error but when
writing to de database it said that one field have too much caracter but
does not specify wich and I dont like it .

thanx for replying to


DbGrid question

Post by Alan Dav » Mon, 25 Jan 1999 04:00:00


Could you not use the dbgrid's BeforeColUpdate event?

Something like this

Private Sub DBGrid1_BeforeColUpdate(ByVal ColIndex As Integer,
OldValue As Variant, Cancel As Integer)

    If Len(DBGrid1.Columns(YOUR_COLUMN)) > MAX_LENGTH Then
        MsgBox "Field To Long"
        Cancel = True
    End If

End Sub

Alan Davis Southampton, England


1. Simple DBGrid Question

I have a two-column unbound DBGrid control on a form that contains data from
a Data control that has its RecordSource property set to a SQL statement.
Now, there is one column in the DBGrid that I want to make sure displays its
text data in all uppercase.  What is the best way to accomplish this.
Please E-mail author.  Thank you.

Jeffrey L. Adam
"For there is nothing neither good nor bad but thinking makes it so ... I
could be bounded in a nutshell and count myself a king of infinite space

-- William Shakespeare
from Hamlet, Act II, Scene ii

2. ASCI codes

3. Another DBGrid question about Memo fields

4. Custom Software Development Available

5. VB6 -DBgrid question - Bar instead of a Cell

6. Which DB for large files?

7. DBGrid question (brain fart)

8. Info AIX 4, Sybase and SSA disk array problem

9. DBGRID question

10. DBGrid Question

11. DBGrid question (repost, got no answer first time)

12. HELP: A DBGrid Question

13. True DBGrid question