I am trying to change the label color of a checkbox on a subform if it is checked.
The code I have so far is: - Private Sub Emergency_Contact_Click()
-
If Me.Emergency Contact = True Then
-
Me.Label23.BackColor = vbYellow
-
Me.Label23.BackStyle = 1
-
Else
-
Me.Label23.ForeColor = RGB(0, 0, 0)
-
Me.Label23.BackStyle = 1
-
End If
-
End Sub
The problem is that when the checkbox is checked, the label is highlighted for all records. I only want the label to be highlighted for the individual record in which the checkbox is checked.
Is there a work-around for this problem?
Thanks,
Yappy
5 13835 NeoPa 32,567
Recognized Expert Moderator MVP
You could look at Conditional Formatting, but otherwise it can't work. See Why Values in Unbound Form Controls do not Persist if you need an explanation why. Conditional Formatting only works with controls that contain data of course though, so you will need to be a little creative.
Conditional Formatting is greyed out when I click on the label or the check box in design view. Does this mean I am unable to use conditional formatting?
NeoPa 32,567
Recognized Expert Moderator MVP
Certainly not for those controls (The label contains no data and the CheckBox has nothing to format).
If you were to create a TextBox though, that reflected the value in the CheckBox, this could be used to highlight checked records. This was where I was leading when I posted "so you will need to be a little creative".
Ok. So I created the text box as you suggested and set the conditional formatting. The formatting is not working. Here is the code that I have in the text box: - =IIf([Emergency Contact]="-1","Yes","NO")
The conditional formatting is as follows:
Field Value is equal to Yes then fill is Yellow
Please help. Thanks!
NeoPa 32,567
Recognized Expert Moderator MVP
You seem to be misunderstandin g the different types of values :
"-1" <> -1
"Yes" <> Yes
The two values on the left are string values, whereas those on the right are numeric (Yes is a Boolean, but also numeric). If you must turn the TextBox value into a string (It would probably suit your purpose better to keep it as the value of [Emergency Contact] and simply use the .Format property to display Yes or No as required.), I would use the following for your IIf() statement as comparing a Boolean value to True or False is superfluous (as it already is either True or False) : - =IIf([Emergency Contact], 'Yes', 'No')
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve |
last post by:
I'm not sure if I should be using tables here to structure the layout or
if CSS is okay. I have a data entry form in which I have floated the
labels to one side, and given them a specific width. With regular input
such as textboxes, everything lines up fine. The problem I'm having is
that I have an unordered list of checkboxes, and only the first item
will line up with the label. The additional checkboxes and their labels
end up being...
|
by: Don |
last post by:
Via JavaScript within the client page containing the checkbox, I'm trying to capture the value of a
checkbox to make a cookie out of it. But, all I get is the defined "ON" value, even when it is
unchecked. I'm using the following construct:
document.cookie = "cpceRememberLoginCookie="+document.getPage1.rememberLogin.value+"; expires=Thr,
01-Jan-2015 00:00:00 GMT";
The actual checkbox value passed in the <form> POST reflects the actual...
|
by: bebop |
last post by:
I'm using three checkbox web controls in C# .NET
and one button, and one labe
Is there a way to "group" these individual checkbox web controls
If so, do I use a for loop, hashtable, array, etc
What I'm looking for is how to determine what checkbox was selected from the three checkbox web controls and have the selected checkbox(es) display in a label
|
by: Lars Netzel |
last post by:
If I put a checkbox in a datagrid (ASP.NET) and set the Autopostback to true
I can catch OnChange event on checkbox but how do I then catch what
DataGridItemIndex is?
Can I use some Event in the Datagrid that will fire off when the Checkbox is
changed?
regards
/Lars
|
by: VB Programmer |
last post by:
Simple: I have a datalist that is holding a bunch of job opportunities.
Beside each opp (in the item template) there's a checkbox that says "apply".
After the datalist there's a button that say's "process". I want to LOOP
through each datalist entry and see if the user checked the check box.
Simple.
I wrote the code, but the checked value is ALWAYS False. Any ideas?
Here's the code...
| |
by: GTi |
last post by:
I want to use a 'smarter' checkbox using span. When a user press the
text the checkbox is checked. But this dos't work as expected. Any
idea?
<span style="cursor:pointer;" onclick="ClickBoxClick('IsProd');">
<input type="checkbox" name="IsProd" value="1" />
Is a Product
</span>
|
by: Chris |
last post by:
Hello,
Is it possible change the default color of a link label and basically
override the client side settings? I need another color on my site for the
links other than Blue (unvisited) and Purple (visited)?
Thanks
|
by: cvijaykrishna |
last post by:
i have a web based website in which i have some 14 tabs(i took labels)
i placed all 14 tabs controls in 14 different views of a multiview and in the
click event of each label i am writing
protected void lbASurgery_Click(object sender, EventArgs e)
{
multiView.ActiveViewIndex = 0;
}
|
by: honey99 |
last post by:
Hi!
i have a problem in firefox.I have a textbox with a laeb for it and a checkbox.i need to disable the textbox as well as label when checkbox is checked.it is working in IE but not in FF.plz check my code and tell me a solution
<td id='abc' name="xyz">
Text
</td>
<Input type="text" readonly name="abc1" style="width:165px;" size = "20" >
in javascript my code is
|
by: blad3runn69 |
last post by:
ms 97
howto call from a label box? thank you :)
Sub Form_Current()
Dim curAmntDue As Currency, lngBlack As Long
Dim lngRed As Long, lngYellow As Long, lngWhite As Long
If Not IsNull(Me!txtPastDue.Value) Then
curAmntDue = Me!txtPastDue.Value
Else
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |