I have a DataGrid name 'dgrIntems' and TextBox name 'txtsubcode' .
Datagrid shows the details when i enter the code in TextBox.otherwise datagrid is empty.

I write folowing code on dgrIntems_Click()

[vb code]
Private Sub dgrIntems_Click()

TxtPar.Text = dgrIntems.Columns(2).Text
TxtRate.Text = dgrIntems.Columns(5).Text
TxtPieces.Text = dgrIntems.Columns(6).Text
checkid = dgrIntems.Columns(0).Text
itemco = dgrIntems.Columns(1).Text
subitemcode = dgrIntems.Columns(3).Text
MonthVal = dgrIntems.Columns(15).Text
QuanV = dgrIntems.Columns(4).Text
End Sub

[/vb code]


If the DataGrid is empty and I click on DataGrid it shows an run time error '9'
i want to show the message in this condition.

how can i handel this error.