Results 1 to 8 of 8
  1. #1
    Kirsti is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172

    Date Function as Field Name


    Hi,

    Is it possible to adjust the SQL in the query to change the field name to a date function?

    Basically, I want: Format(DateAdd("m",-1,Now()),"mmmm") to be my field name.

    Thanks, Kirsti

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Not in an Access query object, tried this before, field names are not dynamic, cannot be set with an expression. What you will see is the expression string as the field name. Try it.
    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
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Yes, I have tried it and that's exactly what I found. I was just hoping for some work-around that someone knew of! That's ok, I'll figure out some other way of getting my data to present the way I want it to.

    Thanks.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I think you'd have to build the SQL of the query in VBA code to be able to concatenate that in as the field name.

    My daughter just got back from NZ; they loved it!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Thanks Paul - I'll give that a go.

    Glad to hear your daughter loved NZ - it's a beautiful place (earthquakes aside)!

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Yes, VBA can build the SQL statement then can use to set RecordSource of form/report but the bound controls will no longer have a valid field reference. However, if you are setting RowSource of a graph object, might work.
    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.

  7. #7
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Ok, thanks June. Will give it a try.

  8. #8
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Ok, being a total dummy when it comes to VBA, I didn't get this working, however I found a work around though creating a new query, as all I really wanted was for the series name in my chart to show the name of the previous month, and I managed to do that within the data rather than changing the field name, so I have marked this thread as closed.

    Thanks again for your help.

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

Similar Threads

  1. Insert date function
    By geraldk in forum Forms
    Replies: 2
    Last Post: 01-01-2012, 06:37 PM
  2. date function
    By geraldk in forum Forms
    Replies: 13
    Last Post: 12-28-2011, 12:36 PM
  3. Date Function
    By joewhitt in forum Queries
    Replies: 7
    Last Post: 07-17-2011, 07:22 PM
  4. Julian Date Function Help Please
    By campanellisj in forum Programming
    Replies: 3
    Last Post: 05-13-2011, 12:59 PM
  5. Date Function
    By tmcrouse in forum Queries
    Replies: 2
    Last Post: 12-02-2010, 08:53 AM

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