Sep 26 2005, 09:42 AM
I have a table called "People" which has all sorts of info about each member of an organization. Name, address, etc. One portion of the table deals with whether or not they are an officer. That's a Yes/No field. If a person is an officer, I need to keep track of the year they became one. Instead of placing a field in the People table to simply store the year, I have used a second table called "FiscalYear" to keep track of the actual start and end date. In my People table I have the ID of the record in the FiscalYear table to determine when they became an officer. Hopefully that makes sense.
My question is how to show the StartYear field from the FiscalYear table on the form for People. I have the text box on the form, but right now it will just show the ID of the fiscal year. I simply need to look up the StartYear using that ID.
Do I need to use a subform for this since the actual data I want to display comes from the FiscalYear table, and not the People table?
Very simple question I'm sure, so thanks in advance for any help.
Sep 26 2005, 09:48 AM
Yes, but you're doing it backwards. In the FiscalYear table you should have the ID of the person along with the years he/she served as an officer. You probably should not need a Yes/No field in the People table. In the FiscalYear table, the ID of the person, the office he held, and the start date and end date of his term.
Then a form/subform will do the trick. You'll have one record in the FiscalYear table for each office a person has held.
Sep 26 2005, 10:06 AM
I'm actually using fiscal year for a variety of things in this database. When the person became a member of the organization, when they became an officer, as well as other areas like receipts of donations.
If we take the year the person joined the organization as a simpler example:
FiscalYearID (to represent when they joined the organization)
* This is what I'd like to show on the form with data about each person.
Does this make sense, and is this the right approach? As I said, I need to use Fiscal Year elsewhere in the database as many things relate to it.
Sep 26 2005, 10:09 AM
Ah, just dawned on me that a combo box showing defined fiscal years would be more appropriate in this case.
New question is how to just show the date portion of the start date field in the combo box? My select statement will return something like "7/1/2004", but I really just want to show the "2004" part.
Edited by: lkelly on Mon Sep 26 11:29:09 EDT 2005.
Sep 26 2005, 10:34 AM
I believe you can use the Year function to return just the year:
Sep 26 2005, 10:40 AM
Where would this Year(...) formatting go? Around the select statement for the combo box? In the query itself. I'm unsure about the syntax.
Sep 26 2005, 01:49 PM
I would put it in the query for the combo box.
Sep 26 2005, 02:59 PM
Thanks, but could you help with the syntax?
Right now it has the standard:
SELECT Fiscal_Year.Start_Year, Fiscal_Year.End_Year FROM Fiscal_Year;
Sep 26 2005, 03:50 PM
SELECT Year(Fiscal_Year.Start_Year) As SY, Fiscal_Year.End_Year FROM Fiscal_Year
Sep 26 2005, 03:59 PM
You're heading for trouble. The recommended way to store data is that each table should store data about exactly one thing. You should have for sure a separate table for donations, probably for other entities as well. Otherwise, you're going to have to use code or extremely complex queries to get what you want from the fiscal year table. The bottom line is that you will have to work very extremely harder than you would otherwise have to work.
Read up on normalization. Any good database reference book can tell you about it. This site also has loads of posts about normalization.
Sep 26 2005, 04:03 PM
Thanks, that works great.
Last question is formatting it to show "StartYear - EndYear" (i.e. 2002-2003) in the combo box.
Appreciate the help.
Sep 26 2005, 04:11 PM
SELECT Year(Fiscal_Year.Start_Year) As SY, Year(Fiscal_Year.End_Year) As EY, Year(Fiscal_Year.Start_Year) & " - " & Year(Fiscal_Year.EndYear) As SYEY FROM Fiscal_Year
You'll probably want to hide the first two columns but use them instead of the displayed column. I no longer remember why you are doing this. LOL
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here