Results 1 to 4 of 4
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486

    query to update field with combined values from another

    This should be easy but I cant seem to get it.


    I have a table that has three fields: AllowedCentury, AllowedYear and AllowedMonth. I created a new field called RealDate and I want to use the Century , Year and Month fields to update it .

    I have tried to concatentate:
    [AllowedMonth] & "/" & 1 & "/" & [AllowedCentury][AllowedYear]

    But that doesn't work.
    I have looked at using date part but it is in three different fields.

    Any Ideas how to update this field using and update query and get a real date field entered?

  2. #2
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    486
    Sorry, of course as soon as I post it I figure it out.

    I needs to be :RealAllowed: [AllowedMonth] & "/" & 1 & "/" & [Allowedcent] & [AllowedYear]

    I need the ampersand in between the last two fields

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    You could also use the DateSerial(year, month, day) function, Which seems a little more intuative to me;

    Code:
    ReallAllowed: DateSerial([Allowedcent] & [AllowedYear],[AllowedMonth],1)
    https://learn.microsoft.com/en-us/of...erial-function
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Join Date
    Apr 2017
    Posts
    1,681
    Quote Originally Posted by tagteam View Post
    I needs to be :RealAllowed: [AllowedMonth] & "/" & 1 & "/" & [Allowedcent] & [AllowedYear]
    Btw. what you get is not a date, it is a datestring! I.e. a text value! And Except in case AllowedMonth field is a 2-character string like '01', you cant compare them properly ('11/1/2023' is less than '2/1/2023', or 'August/1/2023' is less than 'January/1/2023', and anyway e.g. '01/01/2023' is less than '02/01/2000')!

    DateSerial(...) returns a real date!

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

Similar Threads

  1. Combined Field Criteria VBA
    By NickWren in forum Queries
    Replies: 11
    Last Post: 02-12-2018, 03:59 PM
  2. Replies: 15
    Last Post: 10-18-2015, 04:05 PM
  3. Working on an SQL Insert / Update combined
    By robsworld78 in forum Programming
    Replies: 0
    Last Post: 02-23-2012, 10:24 PM
  4. Combined Table Repeating values
    By RedWolf3x in forum Queries
    Replies: 1
    Last Post: 11-02-2011, 04:39 PM
  5. Update Query selecting multiple values in one field
    By Zipster1967 in forum Queries
    Replies: 1
    Last Post: 08-15-2011, 12:22 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