Adding a "yes\No" Prompt to existing Open Form Command button

Kemidan2014

Board Regular
Joined
Apr 4, 2022
Messages
226
Office Version
  1. 365
Platform
  1. Windows
I have a simple Command button that opens a form when clicked. there is No VBA for this, i used the native Command button wizard to create the button.

I would like to add an additional message that pops up when its clicked to which Yes will continue to open the form and No will not open the form.

I have never played with the embedded macros associated with these types of buttons. Is it possible to do this or will i need to change it to a VBA _Onclick Code set up to do this?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I did not understand what kind of button you have.
But if in that button you have a code to open the form, something like this:
VBA Code:
Private Sub CommandButton1_Click()
  UserForm1.Show
End Sub


Then try this
VBA Code:
Private Sub CommandButton1_Click()
  Dim res As VbMsgBoxResult
  res = MsgBox("Do you want to continue?", vbYesNo + vbQuestion)
  If res = vbYes Then
    UserForm1.Show
  End If
End Sub

If it is not the above, then explain with images and examples how you created that button, if you have any code in that button to open the form.

If you have trouble explaining it, you can use images.

--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
 
Upvote 0
1686670709965.png

Clicking "..." Takes you to below.

1686670669186.png
 
Upvote 0
I did not understand what kind of button you have.
But if in that button you have a code to open the form, something like this:
VBA Code:
Private Sub CommandButton1_Click()
  UserForm1.Show
End Sub


Then try this
VBA Code:
Private Sub CommandButton1_Click()
  Dim res As VbMsgBoxResult
  res = MsgBox("Do you want to continue?", vbYesNo + vbQuestion)
  If res = vbYes Then
    UserForm1.Show
  End If
End Sub

If it is not the above, then explain with images and examples how you created that button, if you have any code in that button to open the form.

If you have trouble explaining it, you can use images.

--------------
I hope to hear from you soon.
Respectfully
Dante Amor
--------------​
Dante, looks like you may not have realized you were in the Access forum and provided an Excel solution.
 
Upvote 0
Dante, looks like you may not have realized you were in the Access forum and provided an Excel solution.
🤤 Tienes razon, no puse atencion. Creo que todavía estoy dormido :ROFLMAO:


@Kemidan2014, Sorry for my post, it's my mistake, I put you an answer for VBA Excel.
 
Upvote 0
This can be done either way - embedded macros or code. I don't use macros (in the Access sense of the word macro) so I can only answer in general terms.
One of your macro steps would have to be to call a function which raises a message box in such a way that it returns the choice to that function that the user made. Your macro would then need an If statement that deals with the user response and either opens the form or not. Much easier to do in vba IMO.
 
Upvote 0
Solution
I had changed it to VBA string, I was just curious how possible it was to do using Access Macro as it doesn't seem intuitive to figure out and Google searches like to blend Access macro \ VBA macro together so search results are not fruitful.
 
Upvote 0
Well have a play.
I just tried and it does not even work as the documentation says it should.

1686745781682.png


From the Help
1686745821524.png


Not even going to waste any more time on this.
 
Upvote 0

Forum statistics

Threads
1,215,089
Messages
6,123,058
Members
449,091
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top