Results 1 to 6 of 6
  1. #1
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Including @ in a message box (Access 97)

    I have function I use to validate email addresses, and display a message box if the address is invalid. One of the things I like to put in the message is that there is no @ sign in the address. This works OK in Access 2000, but in 97 the @ sign is treated as a formatting command to make part of the text bold.

    How can I include the @ sign and just have it displayed in the normal way?
    Attached Images Attached Images
    Regards
    John



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

    Re: Including @ in a message box (Access 97)

    I don't have Access 97 available, so this is just a guess. Do @ characters after the first two get displayed? If so, you could use something like

    MsgBox "This e-mail address is not valid.@Correct it or delete it.@An e-mail address must contain one @, no spaces, something to the left of the @ and at least one . with something after it."

    The first two are used for formatting the message.

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

    Re: Including @ in a message box (Access 97)

    You can impersonate an Access 97 MsgBox with bold formatting in A2K or later using Eval function as shown in this example:

    Public Sub BoldMsgBox()

    ' Create phony Access 97-style msgbox w/bold formatting:

    Eval ("Msgbox('ATTENTION DUMMY@Please correct your stupid mistake. " & _
    "@E-mail address must include the ''@'' symbol!!'," & vbExclamation & ",'ERROR MSG')")

    End Sub

    The above sub in A2K/AXP displays a msgbox as illustrated. Note that any "@" symbol after the first two simply truncates rest of msg. I tried various combinations of delimiters, Chr(64) function, etc, none of which worked - either text was truncated, or got syntax error. There may be way to include the @ as a literal, but if so, it's nothing obvious. So may be necessary to create custom msgbox for this purpose.

    HTH
    Attached Images Attached Images

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

    Re: Including @ in a message box (Access 97)

    Thanks, I had forgotten about the possibility of using Eval to get the Access 97 behavior in later versions.

    So it is probably impossible to display an @ in an Access 97 message box. Ken Getz suggests the use of the Windows API function MessageBoxA. See here.

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

    Re: Including @ in a message box (Access 97)

    Thanx for link - if Ken Getz doesn't know of a way to avoid this behavior, then probably nobody does! The Windows MessageBoxA API function should work in Access 97 (tho 'I have no way of testing this). A Windows msgbox is same as VB msgbox, except for some additional parameters and constants. The declarations look like this:

    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

    ' 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&

    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

    Public Const MB_DEFBUTTON1 = &H0&
    Public Const MB_DEFBUTTON2 = &H100&
    Public Const MB_DEFBUTTON3 = &H200&

    Public Const MB_APPLMODAL = &H0&
    Public Const MB_SYSTEMMODAL = &H1000&
    Public Const MB_TASKMODAL = &H2000&

    Sub TestMessageBoxAPI()

    Dim strMsg As String
    strMsg = "ATTENTION DUMMY" & vbCrLf & vbCrLf & _
    "Please correct your stupid mistake. " & vbCrLf & vbCrLf & _
    "E-mail address must include the ''@'' symbol!"

    MessageBox Application.hWndAccessApp, strMsg, "ERROR MSG", MB_ICONEXCLAMATION

    End Sub

    The test sub displays a msgbox as illustrated. Of course you will have to live without the bold formatting. Note that the Windows constants correspond to the VB constants you use with MsgBox. For explanation of why bold formatting not available in A2K & later, see MSKB 242889:

    ACC2000: MsgBox Function Ignores At Sign (@) Formatting

    Excerpt: "In earlier versions of Microsoft Access, you can use the at sign to format portions of the message text in a MsgBox function. When you use two at signs in the text of the MsgBox function, the text delimited by the at sign is separated into three paragraphs in the Message Box, with the first paragraph in bold text. This functionality is provided by the Visual Basic for Applications library (Vba332.dll) in Microsoft Access 97. With the integration of the Microsoft Visual Basic Editor, Microsoft Access 2000 no longer implements Vba332.dll."

    There was no MSKB articles to be found on how to display @ symbol as literal character in ACC 97 msgbox.

    HTH
    Attached Images Attached Images

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Including @ in a message box (Access 97)

    Thanks to Hans and Mark

    The first suggestion of putting some extra @ signs did not work, as the last half of the message was not displayed.

    However, in Mark's answer was a solution. The problem only occurs when you use two @ signs. so yes you can display one @ sign in Access 97, but not two.

    So be rewording my message, the problem is solved.
    Attached Images Attached Images
    Regards
    John



Posting Permissions

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