Results 1 to 9 of 9
  1. #1
    andylynchpe is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Posts
    4

    Question Difficult to find phrasing: Way to associate year of events with entire table of data

    I've had trouble googling it because I don't know exactly how to describe it.



    I have an Access database created where I am inputting data related to two previous events (tblPreviousEvent1 and tblPreviousEvent2). I need to have the year in which each event took place to be easily update-able so I can use this database on different projects. For example, tblPreviousEvent1 happened in 2008 and tblPreviousEvent2 happened in 2015.

    What is the best way to have this done? Obviously I don't want to have a separate field in each table where the user has to manually input the year along with each record.

    I have tried setting up a calculated field with the expression simply being the year, but then I can't create relationships based on that field and that's more difficult than I'd like for the end user to have to do.

    I have tried setting up a macro that sets that field, but then again the variable is set in the macro code, and I don't want to expect the end user to be going in there.

    If I haven't asked this clearly, please let me know and I'll do my best to explain. Thanks.

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    There is a function to extract the year from a date. For example:
    Chosen = Year(tblPreviousEvent1.EventDate)

    Chosen is whatever you want to call it.
    EventDate is a field in tblPreviousEvent1.

  3. #3
    andylynchpe is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Posts
    4
    Thank you for your response.

    The issue with that approach is that requires the user to enter the year/date for every record in the table. I am looking to create a relationship where the date is associated with each record because the record exists in the particular table, i.e. everything in tblPreviousEvent1 took place in 2007. That's what I'm hoping to accomplish.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Do you just mean if a date is 10/05/2008 you want the value 2008?

    If not, suggest you give some example data and say what value you want for each.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    andylynchpe is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Posts
    4
    For example, I want to be able to create a report that says "[Event A Title] occurred in [Year] and included the following: [other data from the table]"

    One way I could easily do that is if each record in the tblPreviousEvent1 table contained a separate instance of the same year value, because all events in this particular table will have occurred in the same year. I'm just looking for a way to eliminate the redundancy of having to repeat the year value in each record in a table.

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Are all the reports the same format except for the Year being listed in the heading?
    If so, you can have code in the report_open event to modify the label or listbox in the heading:
    Code:
    If Me.Recordsource = "tblPreviousEvent1" then
        me.headinglabel = "Data for 2008"
    endif

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Quote Originally Posted by andylynchpe View Post
    For example, I want to be able to create a report that says "[Event A Title] occurred in [Year] and included the following: [other data from the table]"

    One way I could easily do that is if each record in the tblPreviousEvent1 table contained a separate instance of the same year value, because all events in this particular table will have occurred in the same year. I'm just looking for a way to eliminate the redundancy of having to repeat the year value in each record in a table.
    That doesn't help. Please answer my question.

    Do you just mean if a date is 10/05/2008 you want the value 2008?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    andylynchpe is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2018
    Posts
    4
    No, I don't mean that. Sorry - I don't know how to explain it any differently. I appreciate you taking the time to try to help.

  9. #9
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    So you want a report that groups the events within the year?
    Apparently the date is not in the table at all. Is that correct? So the only way you know that the event is in a particular year is by knowing what table it is in.
    Do you want the report to cover all the tables, or just one table at a time?

    Other thoughts:
    The issue with that approach is that requires the user to enter the year/date for every record in the table.
    You can provide for a DateCreated field in the tables and have code automatically insert the date that the record was created. No user typing required.

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

Similar Threads

  1. Associate multiple records from the same table
    By fret hack in forum Database Design
    Replies: 3
    Last Post: 03-27-2018, 02:02 AM
  2. Replies: 4
    Last Post: 09-24-2015, 12:35 PM
  3. Replies: 9
    Last Post: 05-08-2015, 02:36 PM
  4. Query can't find Year data
    By G.King in forum Queries
    Replies: 7
    Last Post: 06-23-2011, 03:07 PM
  5. Can't Find Subform Events
    By vdanelia in forum Forms
    Replies: 4
    Last Post: 02-28-2011, 02:23 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