473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to Show Major Birthdays in a Form or Report?

Hi

I am trying to create a Form in MS Access 2007 that will flag up Members 65th, 70th, 75th, 80th birthdays that are due to happen this year. The query works fine and flags up 2 members, 1 with a 65th birthday and 1 with an 80th birthday this year.

However, all the Birtdays appear on the form, i.e. for the lady with the 65th birthday, it also shows the date for her 70th, 75th and 80th birthdays.

I would like to be able to hide all the irrelevant dates and only show the 65th birthday (i.e. with a date of 2011) for the 1 lady, and only show the 80th birthday (i.e. with a date of 2011) for the 2nd lady.

I have tried doing code for "If [65th Birthday] is true, then Visible = true". Also tried "If Year(Now()) is true then...." but either both entries for the 65th Birthday disappear, or both stay showing.

I just want the one for the lady whose 65th birthday IS this year, to show.

Any ideas?

Thanks.
Viv
Jan 31 '11 #1
4 1803
TheSmileyCoder
2,322 Expert Mod 2GB
Its a bit hard to help when you provide little detail as to the solution you allready have in place. That said I would create a seperate function in a seperate module, lets call it: fBoolAnniversary (A function that returns a boolean, and is related to anniversary calculations
Expand|Select|Wrap|Line Numbers
  1. Public Function fBoolAnniversary(dtBirthday As Date) As Boolean
  2.     'Tells whether this year is a anniversary year for the person
  3.     'Anniversary Years are: 65,70,75,80,85,90.......
  4.     Dim intCurYear As Integer 'Current Year
  5.     intCurYear = Year(Date)
  6.  
  7.     Dim intBirthYear As Integer
  8.     intBirthYear = Year(dtBirthday)
  9.  
  10.     Dim intAge As Integer
  11.     intAge = intCurYear - intBirthYear
  12.     'Notice that this tells us how old she will be this year,
  13.     'not her actual current age
  14.  
  15.     Dim intMod As Integer
  16.     If intAge - 65 < 0 Then
  17.         'Person is not yet in the anniversary range
  18.         fBoolAnniversary = False
  19.         Exit Function
  20.     End If
  21.     If (intAge - 65) Mod 5 = 0 Then
  22.         'Person's age is divisible by 5, so must be a anniversary year
  23.         fBoolAnniversary = True
  24.     Else
  25.         fBoolAnniversary = False
  26.     End If
  27. End Function
Now you can use this in your select query, and simply filter on those records where the function returns true. It will return TRUE for all persons above 60 who' turns 65,70,75..... in the current year, I.e. all those anniversary's for 2011.

I also made a modified version will return True for all those who has a annivesary within 1 year from today.
Expand|Select|Wrap|Line Numbers
  1. Public Function fBoolComingAnniversary(dtBirthday As Date) As Boolean
  2.     'Tells whether this person will have a anniversary within the next year
  3.     'Anniversary Years are: 65,70,75,80,85,90.......
  4.  
  5.     'Calculate age that person will be in 1 year
  6.         'Date 1 year from now
  7.             Dim dtDate As Date
  8.             dtDate = DateAdd("yyyy", 1, Date)
  9.         'Difference in years
  10.             Dim intAge As Integer
  11.             intAge = DateDiff("yyyy", dtBirthday, dtDate)
  12.  
  13.     'Calculate if anniversary will happen
  14.         Dim intMod As Integer
  15.         If intAge - 65 < 0 Then
  16.             'Person is not yet in the anniversary range
  17.             fBoolComingAnniversary = False
  18.             Exit Function
  19.         End If
  20.         If (intAge - 65) Mod 5 = 0 Then
  21.             'Person's age is divisible by 5, so must be a anniversary year
  22.             fBoolComingAnniversary = True
  23.         Else
  24.             fBoolComingAnniversary = False
  25.         End If
  26. End Function
Jan 31 '11 #2
Hi, thanks for such a speedy reply.

You say I have given too little info - well, here goes. I have a query where the Column has a Field name of 65th Birthday, and the calculation is:

Year(DateAdd("yyyy",65,[Member - Date of Birth]))

and the Criteria is : Year(Now())

This outputs a field and finds 1 lady who has her 65th birthday this year.

However, I also have columns in the query to find 70th, 75th etc birthdays this year.

So on the Form I now have Lady 1,with fields showing the year of her 65th birthday, 70th, 75th and 80th birthdays.

But in the VBA code behind this form, I want to be able to only show the fields that show the 2011 year for each person, whether tht 2011 appears in the 65th, 70th, 75th or 80th birthday column. With only 1 field showing per lady, for their birthday that occurs this year.

And I want to do this by making the fields either visible or not. I just cannot find a selection to put in the code which will leave the 65th birthday showing for the 1 lady, but make it invisible for the lady whose 80th birthday occurs this year.

Hope that gives you a bit more info. Thanks for your help.

Viv
Jan 31 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
Dear Viv
I have tried to read your post as well as the original, but still a bit unsure. Is this a continues form you are using?

If you could provide a screenshot of your form, I think it would speak volumes. Perhaps even use Paint to circle the areas you want changed.

EDIT: While your at it, a screenshow of your Query Design window for the form, could also be helpful.
Jan 31 '11 #4
Hi

Yes, my form is a continuous one.

However, I have managed to come up with a solution. In the query, I have created a new field called 65th Birthday This Year, and the calculation is

65th Birthday This Year: IIf([65th Birthday]=Year(Now()),[65th Birthday],0)

This outputs 2011 for the lady whose 65th birthday is this year, and a 0 for the lady whose 80th birthday is this year.

I have repeated for the 70th, 75th, 80th birthdays, and now my form shows the 2011 in the 65th birthday This Year column for the 1 lady, with zeros across the other columns, just as I wanted. This saves me having to scroll across the page looking for the birthday that is due to occur in 2011.

So............ problem solved. Many thanks for your help with this - as it turns out, the solution was simple, I just had not thought of it until you mentioned Continuous Forms, when it occurred to me that "obviously, making the field invisibie would occur on both ladie's lines".

Once again, thanks for your efforts.

Viv
Jan 31 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Scott Sabo | last post by:
I have a form & report based on a query which shows details about employees performance reviews (hire date, review date, review submital date, etc). We do 90 day probation reviews as well and I...
0
by: ghadley_00 | last post by:
MS Access Create form / report with multiple pages using different background images Hi, Would like to have users fill out a multipage form, and then click a print button, which pulls up the...
1
by: MSDousti | last post by:
Hi all, I have written a program, which uses some threads. I call thread t from the main thread, and then after some work t must show a modal window.(e.g. a messagebox) but because t is not the...
4
by: Chad Miller | last post by:
Is there any way to show a model form in an mdi container? - chad chad@predictiveconcepts.com
3
by: yzi | last post by:
I have a list form and a detail form . Before, I open the List form, use form.showDialog(),then I click List Item and open the Detail Form by form.show(). now , user need when the list form...
1
by: Adam Honek | last post by:
Why oh why has MS changed so much in VB.NET I can't even figure out how to show/close a form as formname.show() doesnt work and the following doesn't either: formname.activeform.close() (or...
3
by: Mac Campbell | last post by:
For some unknown reason my mdb seemed to drop a module I had named "Utilities". I tried to copy the module back in from a backup copy and got the error message "<<MyProject>> is currently unable to...
4
by: Delphiscn | last post by:
How to show a ABOUT Form???????? Hello Everyone: I use C# want to Create a Project. In my project. there are two forms. One is main form, and another is a about form. In the about form there...
1
by: athusy | last post by:
hi all, I encountered a small problem while doin my project for my University work. I have to show (call) a form which i hide before. the problem is I have to call that hidden form from a...
3
by: MyWaterloo | last post by:
I am trying to open my purchase orders form and go to the last record. In the on open command I do: DoCmd.GoToRecord , , acLast Seems straight forward enough...but I keep getting this message...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.