If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
I'd like NOT to see something on my form.
I have a date field (for birthdays) on my form but don't know the year of
birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. |
#2
|
|||
|
|||
I'd like NOT to see something on my form.
Hi Sue
Use the on current event and create the following. Assume the text box is called txtBirthday if Year(me![txtBirthday]) = 1900 then me![txtBirthday].Visible = true else me![txtBirthday].Visible=false end if "Sue" wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. |
#3
|
|||
|
|||
I'd like NOT to see something on my form.
On Tue, 1 May 2007 22:58:11 -0400, Sue wrote:
I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. Add an unbound control to your form. =IIf(Year([DateOfBirth])=1900,"",[AgeCalculation]) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#4
|
|||
|
|||
I'd like NOT to see something on my form.
i don't think that is quite what Sue was after - it shows the "birthday"
control when the year of birth is 1900, and not at any other time. Sue, i hope that your "field that calculates age" is actually a calculated control in the form - NOT a field in the underlying table. rule of thumb is to not store calculated values in table, but rather to calculate them on the fly as needed. assuming that you *are* using a calculated control on the form, i'd suggest controlling the "show/no show" in the expression - that way you don't have to depend on VBA to recalculate it at strategic points. try something along the lines of =IIf(Year[BirthdateFieldName])1900,put here the calculation you use to get the age,Null) replace BirthdateFieldName with the correct name of the field, of course. and replace the symbols and the text between them with the expression that calculates age. hth "NevilleT" wrote in message ... Hi Sue Use the on current event and create the following. Assume the text box is called txtBirthday if Year(me![txtBirthday]) = 1900 then me![txtBirthday].Visible = true else me![txtBirthday].Visible=false end if "Sue" wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. |
#5
|
|||
|
|||
I'd like NOT to see something on my form.
I'm a bit confused about how to do this.
My date field is called DOB The calculation for age is =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) (And yes, it is a calculated control in the form.) I've tried plugging in your IIf statement a couple of different ways, but it's not working. I think this is a "user error" (and I'm the user.) Can you please help? Here's what I've tried (with and without the "=" preceding the calculation). =IIf(Year[DOB])1900, =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) Thanks for your help, Tina. "tina" wrote in message ... i don't think that is quite what Sue was after - it shows the "birthday" control when the year of birth is 1900, and not at any other time. Sue, i hope that your "field that calculates age" is actually a calculated control in the form - NOT a field in the underlying table. rule of thumb is to not store calculated values in table, but rather to calculate them on the fly as needed. assuming that you *are* using a calculated control on the form, i'd suggest controlling the "show/no show" in the expression - that way you don't have to depend on VBA to recalculate it at strategic points. try something along the lines of =IIf(Year[BirthdateFieldName])1900,put here the calculation you use to get the age,Null) replace BirthdateFieldName with the correct name of the field, of course. and replace the symbols and the text between them with the expression that calculates age. hth "NevilleT" wrote in message ... Hi Sue Use the on current event and create the following. Assume the text box is called txtBirthday if Year(me![txtBirthday]) = 1900 then me![txtBirthday].Visible = true else me![txtBirthday].Visible=false end if "Sue" wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. |
#6
|
|||
|
|||
I'd like NOT to see something on my form.
When I tried to apply your suggestion, I got the following error message:
"The expression you entered has a function containing the wrong number of arguments." My date form is called DOB The calculation I'm using in the unbound control is: =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) What I attempted to enter is the following: =IIf(Year([DOB])=1900,"",[ =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd"))]) Can you help me to properly rephrase this? Thanks. Sue "fredg" wrote in message .. . On Tue, 1 May 2007 22:58:11 -0400, Sue wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. Add an unbound control to your form. =IIf(Year([DateOfBirth])=1900,"",[AgeCalculation]) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#7
|
|||
|
|||
I'd like NOT to see something on my form.
Remove the second equal sign:
=IIf(Year([DOB])=1900,"",DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd"))) Note that you should put Me.[DOB] to help Access find the field. As well, you don't care about time, so it's better to use Date() than Now(). Also, if DOB is a control on your form as well as a field in the form's recordset, you might need to rename the control to something else. =IIf(Year(Me.[DOB])=1900,"",DateDiff("yyyy",Me.[DOB],Date())+Int(Format(Date(),"mmdd")Format(Me.[DOB],"mmdd"))) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Sue" wrote in message ... When I tried to apply your suggestion, I got the following error message: "The expression you entered has a function containing the wrong number of arguments." My date form is called DOB The calculation I'm using in the unbound control is: =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) What I attempted to enter is the following: =IIf(Year([DOB])=1900,"",[ =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd"))]) Can you help me to properly rephrase this? Thanks. Sue "fredg" wrote in message .. . On Tue, 1 May 2007 22:58:11 -0400, Sue wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. Add an unbound control to your form. =IIf(Year([DateOfBirth])=1900,"",[AgeCalculation]) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#8
|
|||
|
|||
I'd like NOT to see something on my form.
you're close, hon. try this:
=IIf(Year([DOB])1900,Null,DateDiff("yyyy",[DOB],Date())+Int(Format(Date()," mmdd")Format([DOB],"mmdd"))) the above goes all on one line in the control's ControlSource property, regardless of line-wrap in this post. also notice that i changed the Now() function to Date() function. Date() returns today's date, while Now() returns today's date AND the current time. you don't need the current time here, it has no bearing on the calculation. and it's a good idea to get in the habit of choosing the specific function that best suits your needs in a given situation, because often the difference between Date() and Now() *will* have a big impact on what you're doing. hth "Sue" wrote in message ... I'm a bit confused about how to do this. My date field is called DOB The calculation for age is =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) (And yes, it is a calculated control in the form.) I've tried plugging in your IIf statement a couple of different ways, but it's not working. I think this is a "user error" (and I'm the user.) Can you please help? Here's what I've tried (with and without the "=" preceding the calculation). =IIf(Year[DOB])1900, =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) Thanks for your help, Tina. "tina" wrote in message ... i don't think that is quite what Sue was after - it shows the "birthday" control when the year of birth is 1900, and not at any other time. Sue, i hope that your "field that calculates age" is actually a calculated control in the form - NOT a field in the underlying table. rule of thumb is to not store calculated values in table, but rather to calculate them on the fly as needed. assuming that you *are* using a calculated control on the form, i'd suggest controlling the "show/no show" in the expression - that way you don't have to depend on VBA to recalculate it at strategic points. try something along the lines of =IIf(Year[BirthdateFieldName])1900,put here the calculation you use to get the age,Null) replace BirthdateFieldName with the correct name of the field, of course. and replace the symbols and the text between them with the expression that calculates age. hth "NevilleT" wrote in message ... Hi Sue Use the on current event and create the following. Assume the text box is called txtBirthday if Year(me![txtBirthday]) = 1900 then me![txtBirthday].Visible = true else me![txtBirthday].Visible=false end if "Sue" wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. |
#9
|
|||
|
|||
I'd like NOT to see something on my form.
Doug, will the Me keyword work outside of a VBA module? i don't think i've
ever seen that used before in an expression in a calculated control. tia, tina "Douglas J. Steele" wrote in message ... Remove the second equal sign: =IIf(Year([DOB])=1900,"",DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd ")Format([DOB],"mmdd"))) Note that you should put Me.[DOB] to help Access find the field. As well, you don't care about time, so it's better to use Date() than Now(). Also, if DOB is a control on your form as well as a field in the form's recordset, you might need to rename the control to something else. =IIf(Year(Me.[DOB])=1900,"",DateDiff("yyyy",Me.[DOB],Date())+Int(Format(Date (),"mmdd")Format(Me.[DOB],"mmdd"))) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Sue" wrote in message ... When I tried to apply your suggestion, I got the following error message: "The expression you entered has a function containing the wrong number of arguments." My date form is called DOB The calculation I'm using in the unbound control is: =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) What I attempted to enter is the following: =IIf(Year([DOB])=1900,"",[ =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) ]) Can you help me to properly rephrase this? Thanks. Sue "fredg" wrote in message .. . On Tue, 1 May 2007 22:58:11 -0400, Sue wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. Add an unbound control to your form. =IIf(Year([DateOfBirth])=1900,"",[AgeCalculation]) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
#10
|
|||
|
|||
I'd like NOT to see something on my form.
I believe so, but to be honest, I didn't test.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tina" wrote in message ... Doug, will the Me keyword work outside of a VBA module? i don't think i've ever seen that used before in an expression in a calculated control. tia, tina "Douglas J. Steele" wrote in message ... Remove the second equal sign: =IIf(Year([DOB])=1900,"",DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd ")Format([DOB],"mmdd"))) Note that you should put Me.[DOB] to help Access find the field. As well, you don't care about time, so it's better to use Date() than Now(). Also, if DOB is a control on your form as well as a field in the form's recordset, you might need to rename the control to something else. =IIf(Year(Me.[DOB])=1900,"",DateDiff("yyyy",Me.[DOB],Date())+Int(Format(Date (),"mmdd")Format(Me.[DOB],"mmdd"))) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Sue" wrote in message ... When I tried to apply your suggestion, I got the following error message: "The expression you entered has a function containing the wrong number of arguments." My date form is called DOB The calculation I'm using in the unbound control is: =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) What I attempted to enter is the following: =IIf(Year([DOB])=1900,"",[ =DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")Format([DOB],"mmdd")) ]) Can you help me to properly rephrase this? Thanks. Sue "fredg" wrote in message .. . On Tue, 1 May 2007 22:58:11 -0400, Sue wrote: I have a date field (for birthdays) on my form but don't know the year of birth for many of the people I'd like to remember on their birthdays. For them, I put in the year 1900. But for SOME of my contacts, I'd like to know their age (i.e. for "special" birthdays, like sweet 16 or 21 or whatever). I have a second field which calculates age. But I really don't want to see the age "107". So is there a way to ONLY have the age display if the year is 1900? Thanks. Add an unbound control to your form. =IIf(Year([DateOfBirth])=1900,"",[AgeCalculation]) -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail |
Thread Tools | |
Display Modes | |
|
|