Results 1 to 7 of 7

msgbox not working

  1. #1
    Fiddler is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2018
    Posts
    15

    msgbox not working

    This is embarrassing and sorry for the long post. I've worked with MS Access since the mid 1990s and have literally created hundreds of programs. One thing I use to help debug code is quick and easy msgboxes, plus I use them behind forms for various things. I quit programming in 2009 and just recently went back into it with Office 365. I've found out that my quick and easy tool no longer works in this version, and works more like an input box than a msgbox. Am I right? Did it change? Have I failed to set some reference?



    It used to be (down and dirty): msgbox="What a beautiful day" & OptionalParm, vbOkayonly, "MyTitle"
    OR msgbox("What a beautiful day", vbOkayonly, "MyTitle")
    OR (for debugging) msgbox "Code failed here"

    but now I'm *required* to declare a variant and set it up this way:
    dim msgTxt
    msgtxt=msgbox("My cumbersome message")

    If I don't set it up this way I get an error message stating that the right hand value must return a function call. This is more like an input box than a message box (of old).

    Of course, the VBOkayOnly was selected from the intellisense dropdown

    I find I cannot put the "vbOkayOnly" or any other thing after the initial message--it actually fails on the comma. Normally, I don't need to capture the return value of the vbOkayOnly, and I'm wondering if I'm just so rusty I've forgotten how to create a simple msgbox, or if it has changed someway. It's annoying not to be able to create a title without it failing or to do a simple box for code debugging.

    Thanks for any help.

  2. #2
    davegri is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    1,127
    Msgbox("Hello World") -this format is a function
    Msgbox "Hello World" is what you want.

  3. #3
    ridders52's Avatar
    ridders52 is offline Long time standing
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    1,901
    You need some rust remover.

    MsgBox hasn't changed but the button code is VbOKOnly.
    Having said that, there is absolutely no point including that as it is the default setting

    Remove the brackets unless you are using it to check user response to e.g. VbYesNo button

    Code:
    if MsgBox ("some text", vbYesNo+vbQuestion,"title text")=vbYes then
    Colin (Mendip Data Systems), Website, email

    If this has helped, please click the star button and leave a comment

  4. #4
    Fiddler is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2018
    Posts
    15
    Thanks--I could swear I've done it both ways, but I'll check again today at work.

  5. #5
    Fiddler is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2018
    Posts
    15
    Yeah, you're right about the button code. Amazing what you forget when going from memory without intellisense. I seldom use a msgbox this way, but thanks for the reminder as you're right! The rust is cracking off slowly... Time for WD40... Thanks.

  6. #6
    ridders52's Avatar
    ridders52 is offline Long time standing
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    1,901
    LOL
    I read this
    Amazing what you forget when going from memory without intellisense.
    as
    Amazing what you forget when going from memory without intelligence.
    which applies to me far too often
    Colin (Mendip Data Systems), Website, email

    If this has helped, please click the star button and leave a comment

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    4,027
    Regardless of how you use it, Msgbox is a function. The parentheses must not be used unless the Msgbox result is being used, such as when it's assigned to a variable. If the function isn't returning a value, then an error will be raised if parentheses are used.
    - "doesn't work" is no help. What's happening? Error messages? Where??
    - Use code tags for code/sql. Implement changes in copies of your database.
    Irregardless, ain't no such word as "reoccur".

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Can't Remove MsgBox without module not working
    By cm-net in forum Programming
    Replies: 1
    Last Post: 01-20-2018, 06:49 AM
  2. vba MsgBox for some but not all
    By BusDriver3 in forum Macros
    Replies: 18
    Last Post: 12-15-2016, 08:33 PM
  3. Yes No msgbox
    By imintrouble in forum Access
    Replies: 3
    Last Post: 10-14-2011, 01:24 PM
  4. MsgBox
    By Mtyetti in forum Forms
    Replies: 4
    Last Post: 07-27-2011, 12:51 PM
  5. Msgbox And Search Code Not Working Properly
    By vampyr07au in forum Forms
    Replies: 1
    Last Post: 05-02-2011, 04:16 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums