Hello,
Please help...
I have a small application. When I click on a ListView row to Edit the details populated from the MS Access DB, I have the Else statement being executed all the time. Initially the code is attached behind a button named Edit. I have a Refresh button also which is clicked before the Edit button is clicked. Thus I just don't want to click on the OK button on the message box generated from the Else part. I just want to switch the Edit option between the ListView data when the ListView is item is clicked. Please help edit my code below and provide a solution. :confused:
The code is as shown below:
Thanking you in advance.
Private Sub lvData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvData.SelectedIndexChanged
Me.dtmDateOfBirth.Visible = False
Me.txtDateOfBirth.Visible = True
'Check if there is a row selected on the listview
If lvData.SelectedIndices.Count > 0 Then
'Grab the selected index
Dim ItemNo As Integer = lvData.SelectedIndices(0)
EDITMODE = True
NEWMODE = False
lblExecutiveID.Text = lvData.Items(ItemNo).SubItems(0).Text()
txtGivenName.Text = lvData.Items(ItemNo).SubItems(1).Text()
txtFamilyName.Text = lvData.Items(ItemNo).SubItems(2).Text()
cmbGender.Text = lvData.Items(ItemNo).SubItems(3).Text()
txtATSAPosition.Text = lvData.Items(ItemNo).SubItems(4).Text()
txtInstitution.Text = lvData.Items(ItemNo).SubItems(5).Text()
txtCourseOfStudy.Text = lvData.Items(ItemNo).SubItems(6).Text()
cmbYearOfStudy.Text = lvData.Items(ItemNo).SubItems(7).Text()
'If edit then enter the data on the textbox called txtDateOfBirth
txtDateOfBirth.Text = lvData.Items(ItemNo).SubItems(8).Text()
txtHomeVillage.Text = lvData.Items(ItemNo).SubItems(9).Text()
txtHomeDistrict.Text = lvData.Items(ItemNo).SubItems(10).Text()
txtHomeProvince.Text = lvData.Items(ItemNo).SubItems(11).Text()
txtHomeAddress.Text = lvData.Items(ItemNo).SubItems(12).Text()
txtEmail.Text = lvData.Items(ItemNo).SubItems(13).Text()
txtHomePhone.Text = lvData.Items(ItemNo).SubItems(14).Text()
cmbBaptismStatus.Text = lvData.Items(ItemNo).SubItems(15).Text()
txtChurchMembership.Text = lvData.Items(ItemNo).SubItems(16).Text()
txtOtherNotes.Text = lvData.Items(ItemNo).SubItems(17).Text()
txtPhoto.Text = lvData.Items(ItemNo).SubItems(18).Text()
'Display Full name of Staff
lblFullName.Text = txtGivenName.Text & " " & txtFamilyName.Text
'Load the photo when calling this
loadPhoto(lblExecutiveID.Text)
'To stop the message from popping up.
Else
If MessageBox.Show("Please click Refresh and then select the data from the list above to edit", "Select Data", MessageBoxButtons.OK) = Windows.Forms.DialogResult.OK Then
End If
ClearTextBoxes()
End If
End Sub