i want to give focus to a specific column if data entered in a row is not valid.
for example, there are 3 field, code, location, quantity, code has to be entered, location has to be entered, quantity has to be more than zero.
before i exit the row, if location or quantity is not entered, i want to show the message to user 'please enter location' and after use press ok the focus go to location coloumn of the row
also in case quantity is less than zero, show message to the user 'invalid quantity' and on press of ok, focus go to quantity column of the row.
is there a way to achieve this?
thanks in advance.
Parv
Hi Mike,
Thanks for the reply. I was away for a while and didn't get chance to test it. I looked into it but not worked for me.
1st, when i make e.cancel to true then it clear all the data entered in the row. I don't want the data to be get cleared. I'm giving the code for your review. In this case i want to give focus to quantity field if quantity is more than 100 and rest of the cell value suppose to remain there.
Can you give some suggestions to handle it?
Thanks in advance,
Dim aa As Decimal
Dim ab As String
aCell = e.Row.Cells("Quantity") 'Me.UltraGrid1.ActiveRow.Cells("Quantity")
aa = aCell.Value 'e.Row.Cells("Quantity").Value
If aa > 100 Then
ab = aa
'Me.UltraGrid1.Focus()
Me.UltraGrid1.ActiveCell = aCell
e.Cancel = True
End If
End Sub
Hi Parv,
It think you can do this using the BeforeRowUpdate event. You can check the values in the row and if any of them are invalid, you can set e.Cancel to true and Activate the cell you want.
You might also want to take a look at the BeforeRowUpdateCancelAction property. I'm not sure you need it, but this property determines what happens when you cancel BeforeRowUpdate.