insert short date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abouddan
    New Member
    • Feb 2007
    • 42

    insert short date

    Hi all
    I am trying to insert in my table "Table1" a new record.
    This table contains a field "cDate". When using a form to insert in that table the textbox "txtDate' is filled automaticly (row source= date(now) ) and in its format I put "Short Date". The display is very good but when inserting to the table the date field is not short date, it's just as we put in row source "=Now".
    So I tryied to change the propreties of that field from the table desin view to be "short date" and it's input mask to be "99/99/9999" but same result.
    So how can insert in the table a short date?
  • abouddan
    New Member
    • Feb 2007
    • 42

    #2
    Any Help?

    10x

    Comment

    • Toral Shah
      New Member
      • Apr 2007
      • 19

      #3
      hi!!!
      well try changing ur regional and language settings in control panel...
      this will help u i guess

      Comment

      • abouddan
        New Member
        • Feb 2007
        • 42

        #4
        Originally posted by Toral Shah
        hi!!!
        well try changing ur regional and language settings in control panel...
        this will help u i guess
        Thanks for the reply
        But I am thinking about implementing this programm in another PC, is it logic to change the settings for all who will implement it?
        Another thing let's say we did what you just said, If someone in the future changes by misstake this setting, this code become unusful. So I think there is something else.

        Thanks

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          Originally posted by abouddan
          Hi all
          I am trying to insert in my table "Table1" a new record.
          This table contains a field "cDate". When using a form to insert in that table the textbox "txtDate' is filled automaticly (row source= date(now) ) and in its format I put "Short Date". The display is very good but when inserting to the table the date field is not short date, it's just as we put in row source "=Now".
          So I tryied to change the propreties of that field from the table desin view to be "short date" and it's input mask to be "99/99/9999" but same result.
          So how can insert in the table a short date?
          A textbox doesn't have a row source. Are you talking about control source? The control source is what tells the control where to save it's data. By setting it to date(now) it won't save anywhere. You have to set the control source to the field and set the default value to your expression. Or you have to do it through code.

          Also, CDate is a function in Access, I recommend you rename it as it may cause problems later.

          Comment

          • abouddan
            New Member
            • Feb 2007
            • 42

            #6
            Originally posted by Rabbit
            A textbox doesn't have a row source. Are you talking about control source? The control source is what tells the control where to save it's data. By setting it to date(now) it won't save anywhere. You have to set the control source to the field and set the default value to your expression. Or you have to do it through code.

            Also, CDate is a function in Access, I recommend you rename it as it may cause problems later.

            Thanks for your Advice I will change it.
            I mean control source not row source, My mistake. Yes I know it won't save by itself, I am doing it by code when clicking on a button.

            What do you mean by "You have to set the control source to the field and set the default value to your expression"

            Comment

            • pks00
              Recognized Expert Contributor
              • Oct 2006
              • 280

              #7
              The controlsource should be set to the fieldname thats in your table. That way u ensure that textbox is bounded to that field. Any changes u make then are reflected in that textbox.

              Now I assume you want this for new records, have a default date of Now()

              You can do this one of two ways

              in table design, u can set the default value to be Now() so that way no coding is required
              or you can set the Default Value of the field (its a property itself) to Now()

              Note Now returns both date/time. If u just want a date, use Date() or Format(Now(),"S hort Date")

              Comment

              • abouddan
                New Member
                • Feb 2007
                • 42

                #8
                Originally posted by pks00
                The controlsource should be set to the fieldname thats in your table. That way u ensure that textbox is bounded to that field. Any changes u make then are reflected in that textbox.

                Now I assume you want this for new records, have a default date of Now()

                You can do this one of two ways

                in table design, u can set the default value to be Now() so that way no coding is required
                or you can set the Default Value of the field (its a property itself) to Now()

                Note Now returns both date/time. If u just want a date, use Date() or Format(Now(),"S hort Date")

                I did what you said but when quering the table the final result is as I put Now() like I discribe in my first post.

                Comment

                Working...