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? 6 5083
"Robert" <no**@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
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" <no**@none.comwrote in message
news:oz*********************@fe08.news.easynews.co m...
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?
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" <bo*****@localhost.notwrote in message
news:iSDWg.18036$wE5.3238@trnddc02...
>
"Robert" <no**@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
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" <no**@none.comwrote in message
news:p%*********************@fe10.news.easynews.co m...
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" <bo*****@localhost.notwrote in message
news:iSDWg.18036$wE5.3238@trnddc02...
>> "Robert" <no**@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
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" <bo*****@localhost.notwrote in message
news:e0RWg.2024$i84.1447@trnddc01...
>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" <no**@none.comwrote in message
news:p%*********************@fe10.news.easynews.co m...
>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" <bo*****@localhost.notwrote in message news:iSDWg.18036$wE5.3238@trnddc02...
>>> "Robert" <no**@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
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" <no**@none.comwrote in message
news:sD******************@fe01.news.easynews.com.. .
>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" <bo*****@localhost.notwrote in message
news:e0RWg.2024$i84.1447@trnddc01...
>>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" <no**@none.comwrote in message news:p%*********************@fe10.news.easynews.c om...
>>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" <bo*****@localhost.notwrote in message news:iSDWg.18036$wE5.3238@trnddc02...
"Robert" <no**@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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: |
last post by:
Hi,
I am setting the NumericUpDown .Value property and the ValueChanged event
is NOT being fired. Does this ONLY get fired when I change it on the UI and
not programatically?
Thanks
|
by: Robert W. |
last post by:
I want to fire an event within the property of a class. Here's an example:
private bool _canprint;
public bool CanPrint
{
get
{
return _canprint;
}
set
|
by: Marc Robitaille |
last post by:
Hello,
Hello,
I developed a UserControl. It has funny behavior. It is composed of three
controls. A texbox, a combobox and a button. There are three properties to
indicate the visibility of...
|
by: GaryDean |
last post by:
(one of our developers posted this and it got no answer so I'm giving it
another try)
I'm converting a DataGrid utility component that previously used the columns
array to function as it has in...
|
by: |
last post by:
How can i make my form invisible
public class Form1 : System.Windows.Forms.Form
static void Main()
{
|
by: gerry |
last post by:
The PagerSettings.Visible property is not being handled properly by the
GridView control.
The value assigned to this property is not applied until after a postback.
Simplest test :
.aspx...
|
by: Doc John |
last post by:
I have an MDI container with a child Form which will be visible according to
certain events. The problem is that when I set the property Visible to False
and then back to True, the Form will be in...
|
by: =?Utf-8?B?RnJlZHJpaw==?= |
last post by:
Hi
I have a problem in one of my user controls that I cannot find any solution
for.
I'am running C# for Visual studio 2003 and developing a windows application.
The problem is the following:
I...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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...
| |