UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Module To Replicate Msgbox, Access 2010    
 
   
dwilson
post Nov 25 2017, 07:08 PM
Post#1



Posts: 41
Joined: 10-October 17



Has anybody created a function that will replicate the msgbox function but have a timed closure? I can certainly create a bunch of forms to meet my needs, but it seems like there ought to be a function that would work the same as msgbox, including the button arguments (like vbYesNo, vbAbortRetryIgnore, etc) and the return values.
Go to the top of the page
 
DanielPineault
post Nov 25 2017, 08:20 PM
Post#2


UtterAccess VIP
Posts: 5,437
Joined: 30-June 11



The best replacement I've ever found was http://www.devhut.net/2017/03/24/great-acc...ed-message-box/, sure if it has the capability you are looking for though.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
HairyBob
post Nov 26 2017, 08:34 AM
Post#3



Posts: 874
Joined: 26-March 08
From: London


Please see attached - I've done a quick modification which allows you to set an open duration. Run frmLaunchPad and give it a try.

Hope that helps...

Hairy.
Attached File(s)
Attached File  CustomMessageBox.zip ( 258.37K )Number of downloads: 16
 

--------------------
If it was easy, It wouldn't be fun!
Go to the top of the page
 
dwilson
post Nov 26 2017, 01:27 PM
Post#4



Posts: 41
Joined: 10-October 17



Here's a small db that does much of what I have in mind.

The problem is that I don't know how to return data the way the existing msgbox function does:

if response = msgbox(x,y,z) = vbyes, then
do something
endif

My version can populate back to a calling form, but I want something more generic. I want to be able to act on the return within VBA and without having to populate a field.
Attached File(s)
Attached File  msgbox_function.zip ( 162.35K )Number of downloads: 7
 
Go to the top of the page
 
dwilson
post Nov 26 2017, 01:33 PM
Post#5



Posts: 41
Joined: 10-October 17



Hairy Bob:

That looks awesome. I'll play around with it today. Thanks
Go to the top of the page
 
dwilson
post Nov 26 2017, 07:17 PM
Post#6



Posts: 41
Joined: 10-October 17



HarryBob:

This works great. Two questions: in the expression below, what's the variable [ByVal Frm as form]?

gcustmsgbox("test title", vbyesnocancel+vbdefaultbutton2+vbcritical,"test text",[ByVal Frm as form],30)

Also: is there a way to change the background color of the caption bar? Right now it's a dark grey and I would like a blue...
Go to the top of the page
 
HairyBob
post Nov 27 2017, 01:48 AM
Post#7



Posts: 874
Joined: 26-March 08
From: London


Hi dwilson,

In response to your two questions:

The 'ByVal frm as Form' parameter in the function header of gCustMsgBox() holds a reference to the frmLaunchPad form. This function is in the mdlCustMsgBox module:

CODE
Public Function gCustMsgBox(ByVal strPrompt As String, Optional ByVal varButtons As Variant, _
                                Optional ByVal strCaption As String = "", Optional ByVal frm As Form, _
                                                            Optional intSecsDuration As Integer) As Long
    ...


The line that calls the gCustMsgBox function is in the cmdDisplayMessage_Click() event handler of frmLaunchPad:

CODE
Private Sub cmdDisplayMessage_Click()

    ...
    
    lngResponse = gCustMsgBox(Nz(Me.txtPrompt, vbNullString), lngIcon + lngButtons + lngDefButton, _
                                                        Nz(Me.txtCaption, ""), Me, Me.txtOpenDuration)
    ...

End Sub


The argument passed to the frm parameter of the gCustMsgBox() function is the last but one - 'Me' - which is a reference to the open form (in this case frmLaunchPad).

The idea is that if you pass in a reference to the form which calls gCustMsgBox() (in this case frmLaunchPad) that form is hidden when the following line in the Form_Open() event handler of frmCustomMessageBox is executed:

CODE
Private Sub Form_Open(Cancel As Integer)

    ...
    
    If Len(Split(Me.OpenArgs, "¦")(4)) > 0 Then Forms(Split(Me.OpenArgs, "¦")(4)).Visible = False
    
    ...

End Sub


When frmCustomMessageBox is closed, the following code in the gCustMsgBox() function makes the form which opened frmCustomMessageBox (frmLaunchPad) visible again:

CODE
    ...
    
        If Not frm Is Nothing Then
            frm.Visible = True
            Echo True
            DoEvents
        End If
    
    ...


In short, if you want to hide the form which opens the custom message box, pass 'Me' to the frm parameter of gCustMsgBox() and if you want the calling form to remain visible. don't pass in 'Me' - for example:

CODE
Private Sub cmdDisplayMessage_Click()

    ...
    
    lngResponse = gCustMsgBox(Nz(Me.txtPrompt, vbNullString), lngIcon + lngButtons + lngDefButton, _
                                                        Nz(Me.txtCaption, ""), , Me.txtOpenDuration)
    ...

End Sub


I don't think it's possible to change the colour of a form's title bar; however, setting a form's BorderStyle property to 'None' removes the title bar. You could then use a label to hold the caption and place it in the form's header, then you can change the back colour of the header. The problem with this solution is that the form will not be moveable.

HTH...

Hairy.

--------------------
If it was easy, It wouldn't be fun!
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    11th December 2017 - 06:25 AM