Results 1 to 9 of 9
  1. #1
    Perkowski is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    5

    Lightbulb Textbox default value with datetimeyear

    Hi

    I am having an issue trying to add the year at the end of the following line:

    =(1000000*(Month(Now())))+(10000*(Day(Now())))+(10 0*Hour(Now()))+(1*Minute(Now()))

    If I put + (Year(Date())) it doesn't work

    What I want displayed is this: 80911512012

    8 = month
    09 = day
    1151 = time
    2012 = year



    Thanks for any help...I am a Access newb

    Joe

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Welcome to the forum!

    Actually it is working, it is adding 2012 minutes to the number of minutes, but obviously that is not what you had hoped. Since what you are attempting to do is to concatenate the various terms, you should probably use this approach


    Month(Now()) & format(day(now),"00") & format(hour(now()),"00") & format(minute(now()),"00") & year(now())

    The above expression will yield a string not a number. If you want a number, you will need to convert it like so

    cDbl(Month(Now()) & format(day(now),"00") & format(hour(now()),"00") & format(minute(now()),"00") & year(now()))

  3. #3
    Perkowski is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    5
    jzwp11

    Thanks for your help...I entered that into the default value field but I get an error. Not sure why?

    Thx

    Joe

  4. #4
    Perkowski is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    5
    jzwp11

    It seems when the year is added is errors out.....if I remove it it works but doesn't show the year? Probably so simple and my simpleton brain cant get it lol

    Joe

  5. #5
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I assume that the textbox on the form is tied to a field in the table or query to which the form is bound. That field in the table must have its data type set to a double precision number if you are converting the value to a number using the cdbl() function. If you are leaving it as a string, then of course, the data type must be text.

    By the way, if you are using this as a unique identifier for a record, what happens is 2 users enter new records within the same minute? Both will have the same value.

  6. #6
    Perkowski is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    5
    jzwp11

    Thanks for all the help. I looked at the field and its set to "Number". The type double precision isn't listed in the drop down though? Where can I set this at?

    Thx

    Joe

  7. #7
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Sorry for not being more clear. While in design view of the table, click on the field then go to the General tab in the lower pane. Go to the field size property and set it to double.

  8. #8
    Perkowski is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    5
    jzwp11

    Thanks you da man!!!! That worked. I would have tooled around for the next week. Thank you very much!

    Joe

  9. #9
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 02-08-2012, 10:06 AM
  2. Load textbox from another textbox
    By siddel77 in forum Programming
    Replies: 12
    Last Post: 08-30-2011, 01:46 PM
  3. Set default value
    By accessnewb in forum Programming
    Replies: 3
    Last Post: 08-17-2011, 06:24 PM
  4. Replies: 2
    Last Post: 08-06-2011, 12:19 PM
  5. Default value
    By Hatye in forum Access
    Replies: 1
    Last Post: 06-19-2011, 05:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums