+ Reply to Thread
Results 1 to 14 of 14

Testing results from inputbox for a date

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Testing results from inputbox for a date

    I have this code


    Please Login or Register  to view this content.
    Note: end_qrybcklog is at the end of the subroutine.

    Problem is that then the "if" gets executed i get a run-time error.

    how to test input from inputbox. if user hits cancel i want to exit.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Testing results from inputbox for a date

    Hi welchs101, your code looks sound and runs without error for me. Perhaps there is a problem somewhere else in your code that is throwing the error there.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Testing results from inputbox for a date

    I forgot to mention taht "start_date1" is a data type of "date"

    dim start_date1 as date

    sorry about that.........really sorry.



    The only thing i could figure out is the following test:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Testing results from inputbox for a date

    Hi welchs101, I think you need to have the"start_date1" variable declared as a string and then in your code convert it to a date after the input box. I just tried running it while declared as a date and it wouldn't work. Try adapting this to your code:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Testing results from inputbox for a date

    Maybe
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Testing results from inputbox for a date

    The following code also includes handling the inputbox if the user selects cancel:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Testing results from inputbox for a date

    Hi RoyUK,

    Quote Originally Posted by royUK View Post
    Maybe
    Please Login or Register  to view this content.
    This throws an error if the user doesn't input a date "Run Time Error 13, type mismatch"
    Last edited by Mordred; 06-29-2011 at 02:20 PM.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Testing results from inputbox for a date

    I don't get an error with Cancel or inputting numbers. Input letters & it will error
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Testing results from inputbox for a date

    Mordred, i modified your code slightly and well, its not working as i would have expected.

    Here is the code:

    Please Login or Register  to view this content.


    Problem is this: If you input say "5/1/11" what gets out put to the screen is this

    12:00:00 AM

    which is not 5/1/11


    any thoughts? Ideas?

  10. #10
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Testing results from inputbox for a date

    Try:
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Testing results from inputbox for a date

    Thanks.

    but when i hit escape i get an error.

  12. #12
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Testing results from inputbox for a date

    I don't know if this is the best way to go about this but I'm sure someone will tell us if it isn't:
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Testing results from inputbox for a date

    Thanks for the code.

    I found something online about checking for the value "False" as a way of checking if they hit cancel

    so here is the code


    Please Login or Register  to view this content.


    it seems to work.......no issues as yet

    thanks again for your help

  14. #14
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Testing results from inputbox for a date

    royuk,

    just an fyi: I also am trying to get your code to run.....good to learn something here.......anyway, yours always executes the "Not IsNumeric"......i guess this is always true. as such it never gets to the 3rd if then statement.

+ 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