Argument using VBA.VbMsgBoxStyle (1 Viewer)

moke123

AWF VIP
Local time
Today, 13:33
Joined
Jan 11, 2013
Messages
2,801
A week or so ago I came across some code which allows you to add custom buttons to the native message box. It seems that it may be useful at some point so its one to add to my code repository. The one thing I didn't like about it was the method of calling it. I added a function so it can be called with a simple function call with arguments.

One argument is for the msgbox style (ie.vbQuestion, vbCritical,etc) The purpose of the argument is to only provide the Icon for the constant, not the corresponding button styles (ie. 1,2 or 3 buttons,etc.)

I'm declaring the argument as
Code:
Optional Icon as VBA.VbMsgBoxStyle
which is great, it gives me a dropdown of ALL the constants.

My question is if there is any way to limit the the list of constants in the intellisense dropdown to just those constants that correspond to an Icon. (vbQuestion, vbCritical,vbExclamation,vbInformation)

file attached for refernce.
 

Attachments

  • CustonNativeMessageBox.accdb
    456 KB · Views: 53

theDBguy

I’m here to help
Staff member
Local time
Today, 10:33
Joined
Oct 29, 2018
Messages
18,788
Hi. Just a guess, but my take is you'll probably have to declare your own Enum structure using the same constant but limited to the list you want included. For example:

Code:
Public Enum MyMsgBoxStyle
    vbQuestion = 32
    vbCritical = 16
    vbExclamation = 48
    vbInformation = 64
End Enum
Hope that helps...
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:33
Joined
Feb 28, 2001
Messages
22,554
I'll second theDBguy's contention. You would need a special ENUM list because you cannot constrain an extant list, particularly since they come to us through a linked library and we can't get to the source code for same.
 

moke123

AWF VIP
Local time
Today, 13:33
Joined
Jan 11, 2013
Messages
2,801
Thanks DBG

I had tried that earlier and was getting an error.

Just tried again and it works.

Earlier I think I was using the numerical constant as one of the arguments which when trying to combine them probably equated to 3 + 32 rather than the textual vbYesNo + vbQuestion. Now that I'm using the text it works.

Thanks.
 

vba_php

Forum Troll
Local time
Today, 12:33
Joined
Oct 6, 2019
Messages
2,884
that's quite an intuitive accdb moke. I've worked with a lot of people that absolutely hated the message boxes that came with access, and as a result they all insisted on using form objects with smooth asthetics and images to stand in for message box occurrances. you probably aren't interested, but here's an example of a company president's attempt to make a substitute...
 

Attachments

  • custom buttons and messages boxes.jpg
    custom buttons and messages boxes.jpg
    61.5 KB · Views: 53
  • better example of actual message box.jpg
    better example of actual message box.jpg
    74.8 KB · Views: 43
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 10:33
Joined
Oct 29, 2018
Messages
18,788
Thanks DBG

I had tried that earlier and was getting an error.

Just tried again and it works.

Earlier I think I was using the numerical constant as one of the arguments which when trying to combine them probably equated to 3 + 32 rather than the textual vbYesNo + vbQuestion. Now that I'm using the text it works.

Thanks.
Hi. Glad to hear you got it to work. Good luck with your project.
 

Users who are viewing this thread

Top Bottom