+ Reply to Thread
Results 1 to 4 of 4

Recomendation for Database Relationship

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    11

    Recomendation for Database Relationship

    Hi,

    It's been a while since I last used Access.

    I wanted to Assign Many data to a single Day, and Many Days to a Month.

    Something like that:

    Relationship.png

    Form.png

    When I created the form with a sub-form (Table 1 > Table 2, using "Day" as a Relationship), I was expecting that when I changed the month it would automatically update the "day" field. Instead, both forms don't seem to be connected at all.

    I keep receiving "Error 3201: You cannot add or change a record because a related record is required in the table 1".

    What am I forgeting?

    Thank you, very much.
    Last edited by Et_Dux_; 07-05-2018 at 04:33 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Recomendation for Database Relationship

    The way you have the relation set up. In table you can have records like

    Jan | 1
    Jan | 2
    Jan | 3

    In Table 2, you can have records like

    2 | Data 1
    2 | Data 2
    3 | Data 3

    You will be linking the Data element to a day of ANY month.

    Also you should not be using Month, Day and Data as element names since these are reserved words and could get you in trouble.

    The relationship you have outlined doesn't make sense, but if you can explain what it is you are trying to do, maybe we can come up with a set of tables and relationships that can support it.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    09-06-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Recomendation for Database Relationship

    Quote Originally Posted by dflak View Post
    Also you should not be using Month, Day and Data as element names since these are reserved words and could get you in trouble.
    Yeah, sorry. It's been a while and I don't this professionally.

    Context:
    An elderly relative is having some health issues and is collecting some personal measurements (what a called data, previously) on paper.

    There are over 200 observations collected over the past 4 weeks (many observations per day).

    Need:
    I wanted to put those data on a .cls file with three columns: Date (mm/dd/yy), Time (hh:mm), and Measurement (9999).

    I needed a form to facilitate the tabulation.

    Form:
    I was approaching the problem from the interface point of view. One that would allow to report the Measurement only needing to inform the date once.

    Something like this:

    Form.png

    I would concatenate the dates later.

    Unfortunately, couldn't make the relationships work. They were all "one to many" (One year to many months. One Month to many day. Etc.)

    Would you have any suggestions?

    Thank you, very much.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Recomendation for Database Relationship

    You have just three data elements and you don't have a relationship to an outside table. This is a classic "flat file" and could be done in Excel. The data are organized perfectly for a pivot table. The pivot table will do the gathering of the dates for you.

    It can also be done in Access. You would have two tables: One which you populate with dates, and another where you link a date-metric to the date. This makes the first table sort of redundant. Also it is a lot more complicated than it needs to be.

    The attached worksheet has a mock up of the data and what a sample pivot table would look like.

    The data is in an excel table. There are a lot of advantages to an Excel table, one of them being that they automatically copy down formats, data validations and formulas. I have three "helper columns" in the table. I added them just to show the kind of thing that can be done with Excel Tables and Pivot tables.

    Here is information on Excel Tables: http://www.utteraccess.com/wiki/Tables_in_Excel.

    I made two pivot tables:

    One sorts out the measurements by Morning, Mid Day and Night. This pivot table may not be of much value since if you take two measurements during the same time of day, they will be added together.

    The other pivot table is more in line with what you want.

    I put slicers against both tables - Do a web search on slicers. They are easy to implement and are very intuitive. I wanted you to be able to filter date based on Year and Month, so that's why I put those two helper columns in.

    Enter a date in column A immediately below the table and that row becomes part of the table. The formats and formulas are copied down automatically.

    After you enter data, it will not be reflected until you refresh the pivot tables. You can select Data -> Refresh All or you can right click on one of the pivot tables and select refresh. Since both pivot tables are built from the same data source, if you refresh one, the other table refreshes as well.

    You can use this sheet as is. Delete my data (read the wiki on how to delete table rows) and fill in your own data. Since the data are in a table and the pivot tables are built off them, they will follow along. All you have to do is refresh.

    Let me know if I can give you any further help or explanation.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. One to Many Relationship
    By nafischer90 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 03-20-2018, 12:09 PM
  2. [SOLVED] Many to Many Relationship
    By NetherLance in forum Excel General
    Replies: 3
    Last Post: 09-15-2017, 08:29 AM
  3. One to many relationship
    By Bikashmittle in forum Excel General
    Replies: 0
    Last Post: 02-10-2017, 01:42 PM
  4. Create a one to one relationship
    By austenr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2013, 02:43 PM
  5. [SOLVED] Many to many date relationship
    By chaserracer83 in forum PowerPoint Formatting & General
    Replies: 2
    Last Post: 10-08-2012, 02:40 PM
  6. relationship
    By Cboggie in forum Access Tables & Databases
    Replies: 2
    Last Post: 12-22-2011, 08:39 AM
  7. Database table and relationship advise
    By newbie2305 in forum Access Tables & Databases
    Replies: 0
    Last Post: 07-05-2011, 07:09 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1