OK | Cancel Msg Box?

dynamix

Registered User.
Local time
Today, 21:21
Joined
Feb 9, 2005
Messages
38
On a payments table I have, it drags what subscription type the user selected in the previous form.. Upon clicking the command button a message box pops up reminding the usser of what they're about to process.

I would like to add a cancel button to this msg box so its like "You have chosen ____. Okay | Cancel"

The code I am using is:
Private Sub cmdProcessPayment_Click()

Dim str As String

On Error GoTo Err_cmdProcessPayment_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

str = Forms![frmSubscriptions]![cboPlan]
MsgBox str


Exit_cmdProcessPayment_Click:
Exit Sub

Err_cmdProcessPayment_Click:
MsgBox Err.Description
Resume Exit_cmdProcessPayment_Click

End Sub

Thank you so much.
 
Get rid of all that code - some of it is out of date.

Code:
Dim bytResponse As Byte

bytResponse = MsgBox("You have chosen " & Me.cboPlan & ".", vbInformation + vbOkCancel, "Confirm Choice")

If bytResponse = vbOk Then ' user selected OK
    ' do your ok code here
Else ' otherwise, user has selected cancel
    'do your cancel code here
End If
 
Code:
Dim mbrResponse As [B]vbMsgBoxResult[/B]
Dim str As String

mbrResponse = MsgBox("You have chosen " & Me.cboPlan & ".", vbInformation + vbOkCancel, "Confirm Choice")

If mbrResponse = vbOk Then
  'if OK was clicked
    str = Forms![frmSubscriptions]![cboPlan]
    MsgBox str
Else
  'if Cancel was clicked
    MsgBox "You cancelled"
End If

Byte works, I just like to be more descriptive and use the messagebox result enum
 
Last edited:
Hey guys thanks for the help, but I am getting the following error message:

Compile error:
Method or data member not found

Is it because I am supposed to code the parts in the 'comments' bits myself? If so, I don't know how.. :(..

I'm so close I can smell it lol..

Thanks so much for any help at all!
 
The changes are made above, put it in your click code.
 
I am still getting the same erro as described in my previous post. It also brings up the code view with this object name highlighted '.cboPlan'. Which is the combo box it uses to get the string from..

Any ideas?

Thanks again!
 
What version

What is your version of access?

Make sure your combobox NAME is cboPlan, not just the field it's linked to...
 
Damn.. I solved the problem.. I forgot to change cboPlan to the fieldname that it converts to on the payments form which was Plan_Name.

Now it works! Thank you all ever so much, yet again!
 

Users who are viewing this thread

Back
Top Bottom