Results 1 to 4 of 4

Thread: [RESOLVED] Error when creating form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    67

    Resolved [RESOLVED] Error when creating form

    As soon as I click debug, I get the following error:

    InvalidOperationException was Unhandled
    An error occurred creating the form. See Exception.InnerException for details. The error is: Value of '01/01/0001' is not valid for 'SelectionStart'. 'SelectionStart' must be greater than or equal to MinDate.
    Parameter name: SelectionStart

    On my form I have a MonthCalendar control which is what I assume the error is about as I don't have anything else with a SelectionStart property.
    The MinDate for the month calendar is 01/07/2013
    The MaxDate for the month calendar is 31/12/2199

    The Selection range is 17/07/2013, 17/07/2013
    The MaxSelectionCount is 1.

    This happens before the form load event which I have a breakpoint on, so I am not sure where to look to start fixing it.
    It brings it up in a new tab called "No Source Available"

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: [RESOLVED] Error when creating form

    Is DD/MM/YYYY the correct date format for the language you're using on the machine? It should be automatically adjusted but the only explanation for this behaviour I can think of is that it's trying to interpret 17 as a month rather than a day.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    67

    Re: [RESOLVED] Error when creating form

    Sorry, I worked it out before anybody commented but I couldn't work out how to delete the thread.

    The date format was correct.
    The problem was that one of my radio buttons is checked on the form by default, last night I added code so that when you check the radio button, it sets the month calendar's SelectionStart to a variable called CurrentDate.

    However what I didn't realise until now was that other procedures (such as the radio button checked change) can be executed before the form load event.
    My CurrentDate variable hadn't yet been initialised as it is initialised in the form load procedure so it's value was '01/01/0001', this is what caused the error.

    For anybody else who finds this thread, I clicked something like "copy exception info" in the error message and went through the lines of code it said in there one by one until I found the offending line.

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: [RESOLVED] Error when creating form

    Sorry, I worked it out before anybody commented but I couldn't work out how to delete the thread.
    No problem. Marking the thread resolved is the right thing to do but it helps if you just add a note to say how you did it. Not only does it mean we know you didn't just mark it accidentally but it may also be of help to someone else who encounters the problem later.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

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
  •  



Click Here to Expand Forum to Full Width