Results 1 to 7 of 7
  1. #1
    lilanngel is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    7

    Set textbox field to depend on current date

    Hi All,

    Is it possible to link a textbox to a different field, depending on the current date?

    For example:

    If the Current Year: 2011
    Textbox should display: [Total Spend in 2010] field from "All Spend Query"

    But if Current Year: 2012
    Textbox to display: [Total Spend in 2011] field from "All Spend Query"



    Basically... it's the same textbox (but I want it to display different content from the same query, but different fields). I think I can set up another query to equal the field...depending on the year?

    Thank you!!!

  2. #2
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    Quote Originally Posted by lilanngel View Post
    Hi All,

    Is it possible to link a textbox to a different field, depending on the current date?

    For example:

    If the Current Year: 2011
    Textbox should display: [Total Spend in 2010] field from "All Spend Query"

    But if Current Year: 2012
    Textbox to display: [Total Spend in 2011] field from "All Spend Query"

    Basically... it's the same textbox (but I want it to display different content from the same query, but different fields). I think I can set up another query to equal the field...depending on the year?

    Thank you!!!
    Can you post a listing of the fields in your table?

  3. #3
    lilanngel is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    7
    Quote Originally Posted by William McKinley View Post
    Can you post a listing of the fields in your table?
    Hi William!

    Sure! We're setting this Access Database up to handle all of our "Spend" information and we plan to update this with spend numbers each year.

    So the "All Spend Query" Query has the following fields:

    [Total Spend for 2010]
    [Total Spend for 2011]
    [Total Spend for 2012] (currently equals $0)
    [Total Spend for 2013] (currently equals $0)
    [Total Spend for 2014] (currently equals $0)
    Those fields sum up spend information in another table.

    We have a textbox in a form that we want to populate with last year's total spend. I know I can just select the "Total Spend for 2010" field for right now, but I want to make it so that the field will change automatically next year, depending on the current year (Year(Date()). Is there some way I can do this?

    Thank you!!

  4. #4
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    Well, I'm no expert, but initially it would seem that you have some normalization issues. Instead of having a field represent a range of dates, you should have a query to aggregate the individual spending records from your table into these groups.


    See attached database for my quick attempt.

  5. #5
    lilanngel is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    7
    Thank you so much for your response!!

    Unfortunately, as I mentioned before, the Totals are the column headings (fields) and not the year, so dlookup doesn't work.

    We have totals as column headings because we have different departments that we want to keep track of, and we want to display what each department spent last year... which is why we need the textbox to display a different "field" so to say.

    :/

  6. #6
    lilanngel is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    7
    I figured it out!! Thanks!!

  7. #7
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    Quote Originally Posted by lilanngel View Post
    I figured it out!! Thanks!!

    You should really consider analyzing the structure of your database before you get to invested into the current state.

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

Similar Threads

  1. SQL Inner Join where date = current date
    By Tyork in forum Queries
    Replies: 2
    Last Post: 11-07-2010, 02:07 PM
  2. Comparing Date with current Date
    By ds_8805 in forum Forms
    Replies: 7
    Last Post: 03-31-2010, 09:31 PM
  3. Replies: 9
    Last Post: 03-19-2010, 10:37 AM
  4. Current Date Error
    By McFly in forum Database Design
    Replies: 4
    Last Post: 02-04-2010, 09:08 AM
  5. Changing a date to the current year
    By fdnyfish in forum Access
    Replies: 1
    Last Post: 03-01-2008, 08:34 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