Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Picking sound on Msgbox (Access 2000)

    Is there a way to customize the sound that plays on an error or custom msgbox?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Picking sound on Msgbox (Access 2000)

    That is a Windows setting, to be changed in the Sound control panel.

    In a custom message box (i.e. a form made to look like a message box), you can play any sound you like - see <post#=297221>post 297221</post#>.

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Picking sound on Msgbox (Access 2000)

    O OK

    Thanks [img]/forums/images/smilies/smile.gif[/img]

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Picking sound on Msgbox (Access 2000)

    As HansV noted, the sound that plays (if any) when a MsgBox is displayed depends on the user's Windows "Sounds" settings, which are set using Control Panel & saved in Registry. The specific sound that plays is determined by which icon (if any) you choose to display on MsgBox. To see how this works you can run the test sub that follows, which uses the Windows MessageBeep API function to play back the MsgBox standard sounds, followed by a slight pause, then a VB MsgBox and Windows MessageBox that uses same sound:

    Option Explicit

    Declare Function MessageBox Lib "user32" Alias "MessageBoxA" _
    (ByVal hwnd As Long, _
    ByVal lpText As String, _
    ByVal lpCaption As String, _
    ByVal wType As Long) As Long

    Declare Function MessageBeep Lib "user32" (ByVal wType As Long) As Long
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

    ' MessageBox() Flags
    Public Const MB_OK = &H0&
    Public Const MB_OKCANCEL = &H1&
    Public Const MB_ABORTRETRYIGNORE = &H2&
    Public Const MB_YESNOCANCEL = &H3&
    Public Const MB_YESNO = &H4&
    Public Const MB_RETRYCANCEL = &H5&

    ' These can be used with MessageBeep:
    ' &HFFFFFFFF (-1): Standard Beep
    Public Const MB_ICONHAND = &H10&
    Public Const MB_ICONQUESTION = &H20&
    Public Const MB_ICONEXCLAMATION = &H30&
    Public Const MB_ICONASTERISK = &H40&
    Public Const MB_ICONINFORMATION = MB_ICONASTERISK
    Public Const MB_ICONSTOP = MB_ICONHAND 'Critical Stop

    Sub TestMsgBoxIconSound()

    Dim hwnd As Long
    hwnd = Application.hWndAccessApp

    MessageBeep -1
    Sleep 500
    Beep
    Sleep 500

    MessageBeep MB_ICONHAND
    Sleep 500
    MsgBox "Critical", vbCritical, "VB MSG BOX"
    MessageBox hwnd, "Critical", "API MSG BOX", MB_ICONHAND

    MessageBeep MB_ICONEXCLAMATION
    Sleep 500
    MsgBox "Exclamation", vbExclamation, "VB MSG BOX"
    MessageBox hwnd, "Exclamation", "API MSG BOX", MB_ICONEXCLAMATION

    MessageBeep MB_ICONQUESTION
    Sleep 500
    MsgBox "Question", vbQuestion Or vbYesNo, "VB MSG BOX"
    MessageBox hwnd, "Question", "API MSG BOX", MB_ICONQUESTION Or MB_YESNO

    MessageBeep MB_ICONASTERISK
    Sleep 500
    MsgBox "Information", vbInformation, "VB MSG BOX"
    MessageBox hwnd, "Information", "API MSG BOX", MB_ICONINFORMATION

    End Sub

    Note that the Windows API MessageBox looks (and sounds) just like the VB MsgBox; the primary distinction is that the Windows API provides additional constants for some of the parameters, and you can specify the msgbox's "owner" (or "parent") using the hwnd parameter. Except in special cases, you would normally have no need to use the Windows version of the MsgBox in VBA or Access. Note also that a lot of beeps & sounds can get annoying.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •