A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

I'd like NOT to see something on my form.



 
 
Thread Tools Display Modes
  #1  
Old May 2nd, 2007, 03:58 AM posted to microsoft.public.access.forms
Sue[_2_]
external usenet poster
 
Posts: 47
Default 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  
Old May 2nd, 2007, 04:26 AM posted to microsoft.public.access.forms
NevilleT
external usenet poster
 
Posts: 159
Default 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  
Old May 2nd, 2007, 05:06 AM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default 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  
Old May 2nd, 2007, 05:17 AM posted to microsoft.public.access.forms
tina
external usenet poster
 
Posts: 1,997
Default 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  
Old May 2nd, 2007, 01:00 PM posted to microsoft.public.access.forms
Sue[_2_]
external usenet poster
 
Posts: 47
Default 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  
Old May 2nd, 2007, 01:05 PM posted to microsoft.public.access.forms
Sue[_2_]
external usenet poster
 
Posts: 47
Default 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  
Old May 2nd, 2007, 02:28 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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  
Old May 2nd, 2007, 02:33 PM posted to microsoft.public.access.forms
tina
external usenet poster
 
Posts: 1,997
Default 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  
Old May 2nd, 2007, 02:42 PM posted to microsoft.public.access.forms
tina
external usenet poster
 
Posts: 1,997
Default 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  
Old May 2nd, 2007, 03:51 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.