davidwh000
New Member
- Joined
- Jul 18, 2010
- Messages
- 24
Hi Everyone
I have a couple of buttons which cause changes to a form and I would like to add a message box to them to allow for the information to be changed or to be rejected. A simple yes no box with yes completing the process and no leaving the data unchanged. I have posted code below for the 2 buttons affected and for one which is working OK but simply exits the program if accepted.
This one is unmodified and does not have the message function
This one has an experimental message option which does not work.
Would appreciate any help please.
David
I have a couple of buttons which cause changes to a form and I would like to add a message box to them to allow for the information to be changed or to be rejected. A simple yes no box with yes completing the process and no leaving the data unchanged. I have posted code below for the 2 buttons affected and for one which is working OK but simply exits the program if accepted.
This one is unmodified and does not have the message function
VBA Code:
Private Sub cmdReset_Click()
Dim txt
For Each txt In Frame2.Controls
If TypeOf txt Is MSForms.TextBox Then
txt.Text = ""
End If
Next txt
TxtSearch.Text = ""
Dim i
For i = 0 To Me.lstDisplay.ListCount - 1
If Me.lstDisplay.Selected(i) Then Me.lstDisplay.Selected(i) = False
Next i
End Sub
This one has an experimental message option which does not work.
VBA Code:
Private Sub cmdUpdate_Click()
Dim Answer
Answer = MsgBox("Confirm if you want to update the record?", vbYesNo + vbQuestion, "Update Record")
If Answer = vbYes Then
Cells(updateRow, 1) = TxtAccount.Text
Cells(updateRow, 2) = TxtWebsite.Text
Cells(updateRow, 3) = TxtCategory.Text
Cells(updateRow, 4) = TxtOwner.Text
Cells(updateRow, 5) = TxtLogin.Text
Cells(updateRow, 6) = TxtAccdetail.Text
Cells(updateRow, 7) = TxtPassword.Text
Cells(updateRow, 8) = TxtPin.Text
Cells(updateRow, 9) = TxtEmail.Text
Cells(updateRow, 10) = TxtMemword.Text
Cells(updateRow, 11) = TxtExtra.Text
Cells(updateRow, 12) = TxtNotes.Text
End If
End Sub
This is the Exit one which works OK
Private Sub cmdExit_Click()
iExit = MsgBox("Confirm if you want to exit", vbQuestion + vbYesNo, "Data Entry Form")
If iExit = vbYes Then
Unload Me
End If
End Sub
Would appreciate any help please.
David
Last edited by a moderator: