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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Microsoft Data Grid Control: Multiple-Step operation generated errors.

A DataGrid Control is boud to a ADO - Recordset. One of the fields is a Textfield and its lenght is limited to 15 characters. This field is also displayed in the datagrid. After typing characters exceeding 15 characters in this coloumn, the data grid control returns the Multiple Step - error. I'am looking for a method or coloumn-property to limitate the characters for a datagrid - coloumn similar to the maxlenght - property of textfields.
0
mbreit
Asked:
mbreit
1 Solution
 
nmcdermaidCommented:
Put some code in against the KeyPress event for the grid.



The following code will ignore any keys pressed in column 2 when the length of column 2 is 15. It will also beep. It assumes your data grid is called 'DataGridName'


Private Sub DataGridName_KeyPress(KeyAscii As Integer)
  If DataGridName.Col = 1 And Len(DataGridName.Text) > 15 Then
     Beep
     KeyAscii = 0
  End If
End Sub


You can make this dynamic if you refer to the DefinedSize property of the field object which your data grid is bound to.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now