Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Format question (2002)

    Hi,

    I have a form that has a text control [txtstartdate]. It's formatted to be a short date. A user entered the date of 1/1/101 the other day and it accepted it even though it was not a 4 diget year. I'd like to put in a conditional statement that alerts the user if the year is not 4 digits but do not know how to write the syntax other than the if/than piece.

    Thanks!
    Leesha

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Format question (2002)

    One option is to set the Input Mask property of the text box to a short date format, e.g.
    <code>
    00/00/0000;0;_
    </code>
    Another option is to set a validation rule for the text box. For example, set the Validation Rule to
    <code>
    >#01/01/1900#
    </code>
    (You can specify another date, of course)
    Don't forget to enter an appropriate message in the Validation Text property.

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Format question (2002)

    Hi Hans! I can't beleive I didn't see this im my email or respond. I've been up to my eyeballs learning asp.net 2.0 and sql server 2005 express. OMG I must be out of my mind.

    Anyway, you know my need to "understand" the rationale behind the code. On the input mask, what does the ;0;_ after the mask stand for?

    Thanks!
    Leesha

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Format question (2002)

    An input mask can contain up to three sections, separated by semicolons.

    The first section is the actual input mask.

    The second section is optional; if it is 0, literal characters used in the input mask are stored in the table. If it is 1 or omitted, literal characters are not stored. See example below.

    The third section is the placeholder character displayed while you edit the value, for example an underscore _

    Example: for a telephone number you could use
    <code>
    (000) 000-0000;0;_
    </code>
    When you click in an empty phone field, you'll see (_ _ _) _ _ _ -_ _ _ _

    If you enter (415) 527-1685 the phone number will be stored exactly like that because of the 0 in the middle section.

    If you use
    <code>
    (000) 000-0000;1;_
    </code>
    the same phone number would be stored as 4155271685.

  5. #5
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Format question (2002)

    Cool! Excellent information!

    BTW, which of the lounge areas would you suggest for my sql server 2005 database coding questions?

    Thanks!
    Leesha

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Format question (2002)

    If you want to ask a question about SQL or TSQL in SQL Server, this forum (Access) is the best place. If it concerns connecting to SQL server from a web page, the Web Design, Coding and Scripting forum would be better.

  7. #7
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Format question (2002)

    I'm thinking its this forum for this as it is an error it is an error related to the "insert" code I'm using. Yes its for a web page, but the other connections etc. are working correctly so I know this is just my really poor syntax skills! I'll post the question in a new thread and then if I'm in the wrong spot you can redirect it.

    Thanks,
    Leesha

Posting Permissions

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