+ Reply to Thread
Results 1 to 8 of 8

Check that the date is correct on a Userform prior to adding to spreadsheet

  1. #1
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Check that the date is correct on a Userform prior to adding to spreadsheet

    What I'm trying to do is have the userform I created do a date check to be sure that the new data entry is correct (ie advanced by one day). What I have come up with so far is to have the date from the previous row of data show on the userform and have vba check that this date is 1 day prior to the new date being added to the spreadsheet. What I haven't figured out is (1) how to have it reference the date in the prior row (and make this value be uneditable by the end user) and (2) possibly the date check itself (I need to get the first completed to see if the second works). As always, all help is greatly appreciated.

    CheckDate.xlsm

  2. #2
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Re: Check that the date is correct on a Userform prior to adding to spreadsheet

    Anyone? I am open to suggestions that aren't even the same as the idea I have as a solution above.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Check that the date is correct on a Userform prior to adding to spreadsheet

    Is the user actually going to enter the date?
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Re: Check that the date is correct on a Userform prior to adding to spreadsheet

    No, the user will not be entering the second date (previous day). My idea behind this is to try to prevent duplicate and skipped dates on the spreadsheet, an issue that has become a rather large problem when I return from a vacation as I am the one administrating and correcting errors on the spreadsheet.
    Last edited by LoneWolf3574; 03-21-2013 at 06:11 AM.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    If that's the case can't you just find the last date and add the appropriate number of days?

  6. #6
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Re: Check that the date is correct on a Userform prior to adding to spreadsheet

    Originally, I was trying to force the users to think about the date they enter, obviously a fail for me right now

    Thanks for the idea Norie, for some reason doing "Yesterdays Date" that way hadn't occurred to me. A case of trying to make something simple more difficult than it needs to be by me again.

    I have added the following code for the "Todays Date" combobox and the "Yesterdays Date" textbox (activating the locked option for it)

    Please Login or Register  to view this content.
    I would still like to deactivate the cboMidDate line of code and have the txtMidDate2 be a check on its value to ensure that the user is entering the correct date. That way if a date is missed, they are made to enter it before the current date. In other words, the "Todays Date" combobox is never more than 1 day greater than "Yesterdays Date" textbox.

    The updated spreadsheet is below.
    CheckDate.xlsm
    Last edited by LoneWolf3574; 03-22-2013 at 05:11 AM. Reason: added info

  7. #7
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Re: Check that the date is correct on a Userform prior to adding to spreadsheet

    I have done some experimenting and decided upon leaving the "Yesterdays Date" on the userform but trying to have the cboMidDate check itself to see if it is +1 day by using the coding below and having it highlight the combobox background red (that part isn't necessary but nice to have imo).

    Please Login or Register  to view this content.
    But I keep getting an "Invalid Property Value" error message every time I click add. The only way to shut down the userform after this is to use the stop in the VBA window.

    EDIT - If I move the code to the Private Sub cmdAdd_Click section of coding, I keep getting my msgbox regardless of whether or not the date is +1 day or plus anything.
    Last edited by LoneWolf3574; 03-23-2013 at 04:57 AM.

  8. #8
    Forum Contributor
    Join Date
    09-14-2012
    Location
    Tucson, Arizona, USA
    MS-Off Ver
    Office 2010
    Posts
    105

    Re: Check that the date is correct on a Userform prior to adding to spreadsheet

    So far the best solution that I've come up with on my own for this is to take the Sub Next_Date code, alter it some, place it in the Sub Userform_Initialize and made sure to delete the Sub Next_Date coding entirely so that it looks like the following –
    Please Login or Register  to view this content.
    I added the following coding to the Sub cmdAdd_Click to try to make the end user aware –
    Please Login or Register  to view this content.
    And I changed a couple of lines of code in the clear userform commands to eliminate the “Invalid Property Value” error I kept getting and hopefully to “fill out” the form for a little clarity for the end user–
    Please Login or Register  to view this content.
    BTW, just so you all know, the code in red is what was causing my error.

    I still would like for a msgbox error to popup if "Todays Date" is greater than "Yesterdays Date" plus 1 day. I'd love some ideas/help on figuring that out as my current knowledge of VBA is limited to what I've been picking up and learning.
    Last edited by LoneWolf3574; 03-28-2013 at 05:44 AM.

+ 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