I have a datagrid which i use for entering the item information.
On the first column i have item no, which i want to validate if the item no entered is a valid number by checking the item table.
How can i make the focus stay on the first column if the item no is invalid. Below is the code is use.
Code:Private Sub grdDetails_AfterColEdit(ByVal ColIndex As Integer) Select Case ColIndex Case 1 Dim rstItem As ADODB.Recordset Set rstItem = cnn.Execute("select * from tblitems where item_no='" & grdDetails.Columns(ColIndex).Value & "'") If Not rstItem.EOF Then grdDetails.Columns(2).Value = rstItem!item_category grdDetails.Columns(3).Value = rstItem!item_Desc Else MsgBox "Item number not in the table." grdDetails.Col = ColIndex Exit Sub End If Case 4 If IsEmpty(grdDetails.Columns(4)) Or grdDetails.Columns(4).Value = 0 Then MsgBox "Item number not in the table." grdDetails.Col = ColIndex End If End Select End Sub
I can not make the focus stay on the first column. How willi do that?
Another thing. how can i stop user in adding new column if the columns has no data on it?


Reply With Quote