+ Reply to Thread
Results 1 to 11 of 11

Inputbox error message. Formula you typed contains an error.

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Inputbox error message. Formula you typed contains an error.

    I have procedure that prompts the user to input a date into an input box. The issue is if the user clicks 'OK' without entering any data into the input box, the user receives popup message of "Formula you typed contains an error." Is there a line of code I could use so this error does not popup? Instead, I would like the message to say something like "date invalid, would you like to try again". thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Inputbox error message. Formula you typed contains an error.

    Hello maacmaac,

    I assume by the name that sDate is a string variable. Declare it as a Date and the code will work.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Inputbox error message. Formula you typed contains an error.

    I did declare as date but still getting same message if user leaves the field blank. Full code below. Thanks for comments.
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Inputbox error message. Formula you typed contains an error.

    Hello maacmaac,

    When I run the code, I don't receive any error messages for leaving either the start or end date blank. I am running Office 2010 on Windows 7.

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Inputbox error message. Formula you typed contains an error.

    Not sure what I am doing wrong. I attached a copy of screenshots I am getting if that helps. I'm also using 2010 and Windows 7.
    Thanks.
    Attached Files Attached Files

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Inputbox error message. Formula you typed contains an error.

    Hello maacmaac,

    Using the code you posted, I have been unable to duplicate the error. If you post your workbook then I can see if the error occurs on my system.

  7. #7
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Inputbox error message. Formula you typed contains an error.

    Per your request, sample attached. Thanks.
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Inputbox error message. Formula you typed contains an error.

    Hello maacmaac,

    Good news! It fails for me just like it does for you! Now, to find out why.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Inputbox error message. Formula you typed contains an error.

    Hello maacmaac,

    Okay, not sure why my system didn't error when I copied the code and ran it but doesn't matter. In your code I changed sDate and eDate to Variant types and the InputBox to Type 2 (String) instead of Type 1 (Number). The code now checks for an empty string instead of zero. The attached workbook runs on my system and should run on yours as well.
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Re: Inputbox error message. Formula you typed contains an error.

    This is perfect. Thank you.

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Inputbox error message. Formula you typed contains an error.

    Hello maacmaac,

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1