Results 1 to 10 of 10
  1. #1
    Tinara is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    5

    Insertion of Year into table already created


    Help! I'm losing my mind! I have created a table in Access. After the table was created the field "Year Hired" was added. I only want to record the year. I cannot not get this to work and I know it's something simple! I keep getting error messages telling me the validation rule does not match the field property sheet. I have tried every single function DateAdd,DatePart and Year(date). nothing will generate the current year in the field.
    !

    Can someone, anyone PLEASE tell me what I'm doing wrong.

    Tinara

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Do you want to update existing records? Do you have a field with date hired? If so, there is no need to save the year part to table. The year can be extracted from date at any time it is needed.

    Do you want to automatically populate the field for a new record? Can set the textbox DefaultValue to Year(Date()).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Tinara is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    5

    Year Insertion

    Quote Originally Posted by June7 View Post
    Do you want to update existing records? Do you have a field with date hired? If so, there is no need to save the year part to table. The year can be extracted from date at any time it is needed.

    Do you want to automatically populate the field for a new record? Can set the textbox DefaultValue to Year(Date()).
    It doesn't work! This is driving me mad! The task is to auto populate the field "Year Hired" with the current Year. The table is already created. What you suggested puts the date in for new records, but the records already created remain blank. :>(

  4. #4
    Tinara is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    5
    Yes the field is "Year Hired" needs to auto insert current year only. Dates are not referenced anywhere else in the table so can't "pull" year from another field!

  5. #5
    RagJose is offline Seasoned user
    Windows XP Access 2002
    Join Date
    Apr 2012
    Location
    Brazil
    Posts
    42
    What type is your field "Year hired"? Your comment on June7's DefaultValue suggestion makes me believe you have used a Date/Time field type. If you want just year figures in it, it should be Number/Integer. Year(Date()) as DefaultValue will then work. To populate previous records, create and run a simple Update query:

    UPDATE {table} SET [Year Hired] = Year(Date());

    Hope to have helped.

  6. #6
    Tinara is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    5

    Argggggh!

    Quote Originally Posted by RagJose View Post
    What type is your field "Year hired"? Your comment on June7's DefaultValue suggestion makes me believe you have used a Date/Time field type. If you want just year figures in it, it should be Number/Integer. Year(Date()) as DefaultValue will then work. To populate previous records, create and run a simple Update query:

    UPDATE {table} SET [Year Hired] = Year(Date());

    Hope to have helped.
    I entered the command you gave me and it told me it is going to update zero records so what am I doing wrong? I have the field to be updated as [Year Hired]. The table is the Instructor information table. I am entering date as Year(#03/15/2012#)

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Is the field a number datatype and [Year Hired] is the name of field in your table? You want the year 2012 saved for all records?

    UPDATE tablename SET [Year Hired] = 2012;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Tinara is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2012
    Posts
    5

    Insertion of year

    Quote Originally Posted by June7 View Post
    Is the field a number datatype and [Year Hired] is the name of field in your table? You want the year 2012 saved for all records?

    UPDATE tablename SET [Year Hired] = 2012;
    Yes! what does [QUOTE] REPRESENT?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Don't understand your question.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    RagJose is offline Seasoned user
    Windows XP Access 2002
    Join Date
    Apr 2012
    Location
    Brazil
    Posts
    42
    Tinara, can you import just this Instructor Information table into a blank mdb (Access 2002 format) and send us this file so we can take a closer look? In the imported table, you can delete columns that hold confidential data if any.

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

Similar Threads

  1. sub form insertion / right click
    By vthomeschoolmom in forum Forms
    Replies: 4
    Last Post: 12-27-2011, 03:14 PM
  2. Replies: 1
    Last Post: 09-29-2011, 09:39 AM
  3. How do you overwrite a table created in VBA? [DELETE]
    By shubhamgandhi in forum Programming
    Replies: 2
    Last Post: 07-20-2011, 02:22 PM
  4. Automatic Date insertion
    By wbeau in forum Access
    Replies: 0
    Last Post: 03-10-2009, 12:51 PM
  5. Importing a table created in word to Access
    By anthony_f_justin in forum Access
    Replies: 4
    Last Post: 01-04-2006, 09:06 AM

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
  •  
Other Forums: Microsoft Office Forums