Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        ' What this does is when the User selects a record in the DataGridView
        ' it will populate the textbox on the other form with the corresponding
        ' Cell Value.
        frmUpdate.txtFirst.Text = dgv1.CurrentRow.Cells(0).Value.ToString
        frmUpdate.txtLast.Text = dgv1.CurrentRow.Cells(1).Value.ToString
        frmUpdate.txtAddress.Text = dgv1.CurrentRow.Cells(2).Value.ToString
        frmUpdate.txtCity.Text = dgv1.CurrentRow.Cells(3).Value.ToString
        frmUpdate.txtZip.Text = dgv1.CurrentRow.Cells(4).Value.ToString
        frmUpdate.txtPhone.Text = dgv1.CurrentRow.Cells(5).Value.ToString
        frmUpdate.txtEmail.Text = dgv1.CurrentRow.Cells(6).Value.ToString
        frmUpdate.txtID.Text = dgv1.CurrentRow.Cells(7).Value.ToString
    End Sub

the problem lays in dgv1.CurrentRow
if u do

if dgv1.CurrentRow is nothing then
msgbox "nothing"
end if

im sure the messagebox will popup.

use this code instead:

If dgv.SelectedRows.Count > 0 Then
			With dgv.SelectedRows(0)
				frmUpdate.txtFirst.Text = .Cells(0).Value.ToString
				frmUpdate.txtLast.Text = .Cells(1).Value.ToString
				frmUpdate.txtAddress.Text = .Cells(2).Value.ToString
				frmUpdate.txtCity.Text = .Cells(3).Value.ToString
				frmUpdate.txtZip.Text = .Cells(4).Value.ToString
				frmUpdate.txtPhone.Text = .Cells(5).Value.ToString
				frmUpdate.txtEmail.Text = .Cells(6).Value.ToString
				frmUpdate.txtID.Text = .Cells(7).Value.ToString
			End With
		End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.