Datagrid mousedown event

irri
09-01-2003, 04:16 AM
basically what i need is a way to bypass the fact that a person can click unther last row of the the datagrid so it doesn't create an error that there is no valid row availible.

Private Sub Datagrid_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Datagrid.Row = Datagrid.RowContaining(Y)
txtID.Text = rst.Fields(0) 'textbox is filled wit recordset value
end sub


I dont want to do this with catching errors.

Rookie
09-01-2003, 04:18 AM
This is how i would do it...

Private Sub Datagrid_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

On Error Goto SkipDataGridClick

Datagrid.Row = Datagrid.RowContaining(Y)
txtID.Text = rst.Fields(0) 'textbox is filled wit recordset value

SkipDataGridClick:
End Sub

that way if an error does happen it just ignores it and leaves everything alone as it was.

irri
09-01-2003, 05:02 AM
This is how i would do it...

Private Sub Datagrid_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

On Error Goto SkipDataGridClick

Datagrid.Row = Datagrid.RowContaining(Y)
txtID.Text = rst.Fields(0) 'textbox is filled wit recordset value

SkipDataGridClick:
End Sub

that way if an error does happen it just ignores it and leaves everything alone as it was.

Yeah, i'm aware of that function, but i have an error handler which i want to use, so do you know another way ?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum