Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 10th, 2006, 02:05 AM
Robert
Guest
 
Posts: n/a
Default .visible property not firing

Quick question about the visible property on a form control. I have a label
that displays a message if a certain criteria is met. By default the label
is visible. I want access to compare a calculated field on a tab page with a
control on the main part of the form:
If Me.CalculatedControl = Me.MainFormControl Then
Me.MessageLabel.Visible = False
End If

I can't figure out where to put this to make it fire. Do I need to reference
the tab page somehow?


  #2  
Old October 10th, 2006, 03:35 AM
Larry Linson
Guest
 
Posts: n/a
Default Re: .visible property not firing


"Robert" <none@none.comwrote
Quote:
Quick question about the visible property on a form control. I have a
label that displays a message if a certain criteria is met. By default the
label is visible. I want access to compare a calculated field on a tab
page with a control on the main part of the form:
If Me.CalculatedControl = Me.MainFormControl Then
Me.MessageLabel.Visible = False
End If
>
I can't figure out where to put this to make it fire. Do I need to
reference the tab page somehow?
Properties do not "fire." Events "fire."

At what point can the criteria be met? If in the Record itself, code goes
in OnCurrent; if it can change, or only changes when the user makes some
entry, code goes in the AfterUpdate of the Control where the user enters the
value. Oh, yes, you'll need code that tests and sets both Visible = False
and Visible = True. If you set it False for one Record, it won't
automatically reset to True for the next one.

Larry Linson
Microsoft Access MVP


  #3  
Old October 10th, 2006, 04:55 AM
tina
Guest
 
Posts: n/a
Default Re: .visible property not firing

to add a note to Larry's response, you can use "toggle" code to set the
label's Visible property, which gives the same result as If...Then...Else,
but is simply shorter, as

Me!MessageLabel.Visible = Not (Me!CalculatedControl =
Me!MainFormControl)

the above goes all on one line in (as Larry mentioned), the main form
control's AfterUpdate event procedure and/or the form's Current event
procedure, as needed.

hth


"Robert" <none@none.comwrote in message
news:ozCWg.242603$Pi2.121327@fe08.news.easynews.co m...
Quote:
Quick question about the visible property on a form control. I have a
label
Quote:
that displays a message if a certain criteria is met. By default the label
is visible. I want access to compare a calculated field on a tab page with
a
Quote:
control on the main part of the form:
If Me.CalculatedControl = Me.MainFormControl Then
Me.MessageLabel.Visible = False
End If
>
I can't figure out where to put this to make it fire. Do I need to
reference
Quote:
the tab page somehow?
>
>

  #4  
Old October 10th, 2006, 12:45 PM
Robert
Guest
 
Posts: n/a
Default Re: .visible property not firing

My form has a tab control on the bottom. Page 1 and Page 2 contain a subform
on which I have a calculated control that totals a column. Page 3,
references each of those calculated fields to make a third calculation. I
want to compare that third calculation with a field on the main form and if
they are not equal, display a warning message. I have tried that code in the
onopen, onactivate, oncurrent, onload, etc for the form and even tried
onclick for the tab control, so I'm not sure where it should go since none
of them have worked. I tried to do something similar to test the process by
puting a label on the main form and using an if statement to compare another
feild to hard coded text (i.e. If Me.FieldA = "Text") and this worked fine.
The label did not appear when fieldA = text and it did if they didn't match.
I put this in the OnOpen event of the form. So it seems as though access
doesn't compare the calc field on page 3 when the form is opened (because it
is not on the first page viewed when the form is opened?)

"Larry Linson" <bouncer@localhost.notwrote in message
news:iSDWg.18036$wE5.3238@trnddc02...
Quote:
>
"Robert" <none@none.comwrote
>
Quote:
>Quick question about the visible property on a form control. I have a
>label that displays a message if a certain criteria is met. By default
>the label is visible. I want access to compare a calculated field on a
>tab page with a control on the main part of the form:
> If Me.CalculatedControl = Me.MainFormControl Then
> Me.MessageLabel.Visible = False
> End If
>>
>I can't figure out where to put this to make it fire. Do I need to
>reference the tab page somehow?
>
Properties do not "fire." Events "fire."
>
At what point can the criteria be met? If in the Record itself, code goes
in OnCurrent; if it can change, or only changes when the user makes some
entry, code goes in the AfterUpdate of the Control where the user enters
the value. Oh, yes, you'll need code that tests and sets both Visible =
False and Visible = True. If you set it False for one Record, it won't
automatically reset to True for the next one.
>
Larry Linson
Microsoft Access MVP
>
>

  #5  
Old October 10th, 2006, 06:35 PM
Larry Linson
Guest
 
Posts: n/a
Default Re: .visible property not firing

A little complex... and given that there are two subforms involved, and
referenced for a calculation, not necessarily easy to determine. Frankly, I
try to avoid an interface as complicated as you describe, not because of
Access, but because I find that multi-page Forms, etc., can be confusing to
the user.

OnOpen is not a good event from which to be trying to do anything to
Controls, because generally the Controls and content are not available that
early in the process. I can only guess that your code worked there because
you were referencing the a Field in the underlying RecordSource and a VBA
constant, not a Control.

Try the OnCurrent event of the main Form, and the OnCurrent each of the
Forms embedded in the Subform Controls. Unfortunately, I don't believe any
event is triggered by the calculation of a value in a Calculated Control.

And, if on this Form, any Control that is a factor in any of the
calculations can be manually entered, you need to fire your code from that
Control's AfterUpdate.

Larry Linson
Microsoft Access MVP


"Robert" <none@none.comwrote in message
news:p%LWg.427482$Jn2.215035@fe10.news.easynews.co m...
Quote:
My form has a tab control on the bottom. Page 1 and Page 2 contain a
subform on which I have a calculated control that totals a column. Page 3,
references each of those calculated fields to make a third calculation. I
want to compare that third calculation with a field on the main form and
if they are not equal, display a warning message. I have tried that code
in the onopen, onactivate, oncurrent, onload, etc for the form and even
tried onclick for the tab control, so I'm not sure where it should go
since none of them have worked. I tried to do something similar to test
the process by puting a label on the main form and using an if statement
to compare another feild to hard coded text (i.e. If Me.FieldA = "Text")
and this worked fine. The label did not appear when fieldA = text and it
did if they didn't match. I put this in the OnOpen event of the form. So
it seems as though access doesn't compare the calc field on page 3 when
the form is opened (because it is not on the first page viewed when the
form is opened?)
>
"Larry Linson" <bouncer@localhost.notwrote in message
news:iSDWg.18036$wE5.3238@trnddc02...
Quote:
>>
>"Robert" <none@none.comwrote
>>
Quote:
>>Quick question about the visible property on a form control. I have a
>>label that displays a message if a certain criteria is met. By default
>>the label is visible. I want access to compare a calculated field on a
>>tab page with a control on the main part of the form:
>> If Me.CalculatedControl = Me.MainFormControl Then
>> Me.MessageLabel.Visible = False
>> End If
>>>
>>I can't figure out where to put this to make it fire. Do I need to
>>reference the tab page somehow?
>>
>Properties do not "fire." Events "fire."
>>
>At what point can the criteria be met? If in the Record itself, code
>goes in OnCurrent; if it can change, or only changes when the user makes
>some entry, code goes in the AfterUpdate of the Control where the user
>enters the value. Oh, yes, you'll need code that tests and sets both
>Visible = False and Visible = True. If you set it False for one Record,
>it won't automatically reset to True for the next one.
>>
>Larry Linson
>Microsoft Access MVP
>>
>>
>
>

  #6  
Old October 11th, 2006, 08:15 PM
Robert
Guest
 
Posts: n/a
Default Re: .visible property not firing

I found it! The solution for those who stumble across this thread in the
future was to put the code in the OnTimer event. I set the timer at 500ms
and it seems to do the trick. I suppose the problem with many of the other
events was their timing in relation to the calculation of the control. On
occasion I could open the form and click on the offending page and just
catch the calc. controls filling with data. So I suspect that when the form
opened, access made the comparison between the two fields before making the
calculations, thus the two were never equal. By using the timer, access has
time to make the calculation then the comparison and it works perfectly now.

"Larry Linson" <bouncer@localhost.notwrote in message
news:e0RWg.2024$i84.1447@trnddc01...
Quote:
>A little complex... and given that there are two subforms involved, and
>referenced for a calculation, not necessarily easy to determine. Frankly, I
>try to avoid an interface as complicated as you describe, not because of
>Access, but because I find that multi-page Forms, etc., can be confusing to
>the user.
>
OnOpen is not a good event from which to be trying to do anything to
Controls, because generally the Controls and content are not available
that early in the process. I can only guess that your code worked there
because you were referencing the a Field in the underlying RecordSource
and a VBA constant, not a Control.
>
Try the OnCurrent event of the main Form, and the OnCurrent each of the
Forms embedded in the Subform Controls. Unfortunately, I don't believe any
event is triggered by the calculation of a value in a Calculated Control.
>
And, if on this Form, any Control that is a factor in any of the
calculations can be manually entered, you need to fire your code from that
Control's AfterUpdate.
>
Larry Linson
Microsoft Access MVP
>
>
"Robert" <none@none.comwrote in message
news:p%LWg.427482$Jn2.215035@fe10.news.easynews.co m...
Quote:
>My form has a tab control on the bottom. Page 1 and Page 2 contain a
>subform on which I have a calculated control that totals a column. Page
>3, references each of those calculated fields to make a third
>calculation. I want to compare that third calculation with a field on the
>main form and if they are not equal, display a warning message. I have
>tried that code in the onopen, onactivate, oncurrent, onload, etc for the
>form and even tried onclick for the tab control, so I'm not sure where it
>should go since none of them have worked. I tried to do something similar
>to test the process by puting a label on the main form and using an if
>statement to compare another feild to hard coded text (i.e. If Me.FieldA
>= "Text") and this worked fine. The label did not appear when fieldA =
>text and it did if they didn't match. I put this in the OnOpen event of
>the form. So it seems as though access doesn't compare the calc field on
>page 3 when the form is opened (because it is not on the first page
>viewed when the form is opened?)
>>
>"Larry Linson" <bouncer@localhost.notwrote in message
>news:iSDWg.18036$wE5.3238@trnddc02...
Quote:
>>>
>>"Robert" <none@none.comwrote
>>>
>>>Quick question about the visible property on a form control. I have a
>>>label that displays a message if a certain criteria is met. By default
>>>the label is visible. I want access to compare a calculated field on a
>>>tab page with a control on the main part of the form:
>>> If Me.CalculatedControl = Me.MainFormControl Then
>>> Me.MessageLabel.Visible = False
>>> End If
>>>>
>>>I can't figure out where to put this to make it fire. Do I need to
>>>reference the tab page somehow?
>>>
>>Properties do not "fire." Events "fire."
>>>
>>At what point can the criteria be met? If in the Record itself, code
>>goes in OnCurrent; if it can change, or only changes when the user makes
>>some entry, code goes in the AfterUpdate of the Control where the user
>>enters the value. Oh, yes, you'll need code that tests and sets both
>>Visible = False and Visible = True. If you set it False for one Record,
>>it won't automatically reset to True for the next one.
>>>
>>Larry Linson
>>Microsoft Access MVP
>>>
>>>
>>
>>
>
>

  #7  
Old October 11th, 2006, 08:15 PM
Jimmy
Guest
 
Posts: n/a
Default Re: .visible property not firing

Sorry, posted that last message to soon. With the OnTimer event, access will
make that check every 500ms while the form is open. Is this a bad idea as
far as comp. memory would be concerned. I figure by doing it this way I
would eliminate having to refresh or requery at any time if info changes.

"Robert" <none@none.comwrote in message
news:sDbXg.10586$FU7.1820@fe01.news.easynews.com.. .
Quote:
>I found it! The solution for those who stumble across this thread in the
>future was to put the code in the OnTimer event. I set the timer at 500ms
>and it seems to do the trick. I suppose the problem with many of the other
>events was their timing in relation to the calculation of the control. On
>occasion I could open the form and click on the offending page and just
>catch the calc. controls filling with data. So I suspect that when the form
>opened, access made the comparison between the two fields before making the
>calculations, thus the two were never equal. By using the timer, access has
>time to make the calculation then the comparison and it works perfectly
>now.
>
"Larry Linson" <bouncer@localhost.notwrote in message
news:e0RWg.2024$i84.1447@trnddc01...
Quote:
>>A little complex... and given that there are two subforms involved, and
>>referenced for a calculation, not necessarily easy to determine. Frankly,
>>I try to avoid an interface as complicated as you describe, not because of
>>Access, but because I find that multi-page Forms, etc., can be confusing
>>to the user.
>>
>OnOpen is not a good event from which to be trying to do anything to
>Controls, because generally the Controls and content are not available
>that early in the process. I can only guess that your code worked there
>because you were referencing the a Field in the underlying RecordSource
>and a VBA constant, not a Control.
>>
>Try the OnCurrent event of the main Form, and the OnCurrent each of the
>Forms embedded in the Subform Controls. Unfortunately, I don't believe
>any event is triggered by the calculation of a value in a Calculated
>Control.
>>
>And, if on this Form, any Control that is a factor in any of the
>calculations can be manually entered, you need to fire your code from
>that Control's AfterUpdate.
>>
> Larry Linson
> Microsoft Access MVP
>>
>>
>"Robert" <none@none.comwrote in message
>news:p%LWg.427482$Jn2.215035@fe10.news.easynews.c om...
Quote:
>>My form has a tab control on the bottom. Page 1 and Page 2 contain a
>>subform on which I have a calculated control that totals a column. Page
>>3, references each of those calculated fields to make a third
>>calculation. I want to compare that third calculation with a field on
>>the main form and if they are not equal, display a warning message. I
>>have tried that code in the onopen, onactivate, oncurrent, onload, etc
>>for the form and even tried onclick for the tab control, so I'm not sure
>>where it should go since none of them have worked. I tried to do
>>something similar to test the process by puting a label on the main form
>>and using an if statement to compare another feild to hard coded text
>>(i.e. If Me.FieldA = "Text") and this worked fine. The label did not
>>appear when fieldA = text and it did if they didn't match. I put this in
>>the OnOpen event of the form. So it seems as though access doesn't
>>compare the calc field on page 3 when the form is opened (because it is
>>not on the first page viewed when the form is opened?)
>>>
>>"Larry Linson" <bouncer@localhost.notwrote in message
>>news:iSDWg.18036$wE5.3238@trnddc02...
>>>>
>>>"Robert" <none@none.comwrote
>>>>
>>>>Quick question about the visible property on a form control. I have a
>>>>label that displays a message if a certain criteria is met. By default
>>>>the label is visible. I want access to compare a calculated field on a
>>>>tab page with a control on the main part of the form:
>>>> If Me.CalculatedControl = Me.MainFormControl Then
>>>> Me.MessageLabel.Visible = False
>>>> End If
>>>>>
>>>>I can't figure out where to put this to make it fire. Do I need to
>>>>reference the tab page somehow?
>>>>
>>>Properties do not "fire." Events "fire."
>>>>
>>>At what point can the criteria be met? If in the Record itself, code
>>>goes in OnCurrent; if it can change, or only changes when the user
>>>makes some entry, code goes in the AfterUpdate of the Control where the
>>>user enters the value. Oh, yes, you'll need code that tests and sets
>>>both Visible = False and Visible = True. If you set it False for one
>>>Record, it won't automatically reset to True for the next one.
>>>>
>>>Larry Linson
>>>Microsoft Access MVP
>>>>
>>>>
>>>
>>>
>>
>>
>
>

 

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles