I am developing a new Application and am getting the below error

Error Description:
When I click the record in DataGrid, then the values should be populated from DataGrid columns to respective Text boxes.

However if i click in the datagrid when there is no record then there should not be any action.

Now the problem is I am getting error "RowSet Not Available" on clicking the data when there is no record.

My code is below

Private Sub DataGrid1_Click()
Dim MyConn As ADODB.Connection
Dim MyRecSet1 As New ADODB.Recordset
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=SQLOLEDB;Data Source=TGS-689\SQLEXPRESS;Initial Catalog=RMG;User Id=RMG;Password=Thinksoft"
    If AddLongLeave.DataGrid1.SelBookmarks.Count = 0 Then
    Exit Sub
    End If
    Emp_Id = AddLongLeave.DataGrid1.Columns(0).Value
    Set MyRecSet1 = MyConn.Execute("Select Count(*) As Cunt from dbo.Emp_Long_Leave where Emp_Id = '" & Emp_Id & "' and Status = 'On Leave'")
    If MyRecSet1![Cunt] > 0 Then
        MsgBox "The selected Emp_Id is already in long leave. Please use edit option if want to extend the leave", vbOKOnly, "Alert"
    Exit Sub
    End If
    Set MyRecSet1 = MyConn.Execute("Select Emp_Name, Designation from dbo.Employee where Emp_Id = '" & Emp_Id & "'")
    AddLongLeave.TBEmpCode.Text = Emp_Id
    AddLongLeave.TBEmpName.Text = MyRecSet1![Emp_Name]
    AddLongLeave.Combo_Desg.Text = MyRecSet1![Designation]
End Sub

As this is urgent, i am looking forward your quick help

You could use the ".ApproxCount" property of the Datagrid. If it is bound and open then you could use this property to check if there are any rows in the grid.

If there are no rows available, exit your sub or disable the grid so no click event can be fired when clicking on it.:)