473,327 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Hide Labels depending on checkbox value

3 2Bits
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox [active] being checked or not. Below is the code. Visibility is not adhering to the record [active] checkbox value. Screenshot also below. Any ideas?
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Dim db As DAO.Database
  3.     Set db = CurrentDb
  4.  
  5.     lblinactive.Visible = False
  6.     lblactive.Visible = False
  7.  
  8. '+++++++++++++++++++++++
  9.  
  10.     If Me.active.Value = 0 Then
  11.         lblinactive.Visible = True
  12.         lblactive.Visible = False
  13.     Else
  14.         lblinactive.Visible = False
  15.         lblactive.Visible = True
  16.     End If
  17. End Sub

Jun 7 '23 #1

✓ answered by NeoPa

Hi ezappsrUS.

Welcome to Bytes.com :-)

Please read and understand Why Values in Unbound Form Controls do not Persist in order to understand why it might work for Single Forms but not Continuous ones.

You may want to consider Conditional Formatting to manage showing each record correctly. That wouldn't require code to update every time you move between records.

BTW, your routine can be considerably simplified to :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.lblActive.Visible = Me.Active
  3.     Me.lblInactive.Visible = (Not Me.Active)
  4. End Sub

4 24106
ezappsrUS
3 2Bits
Additionally, if I change to single form then code works when paging down. Form is needed to show many records (continuous) for users to view and choose. Thanks again.
Jun 7 '23 #2
NeoPa
32,556 Expert Mod 16PB
Hi ezappsrUS.

Welcome to Bytes.com :-)

Please read and understand Why Values in Unbound Form Controls do not Persist in order to understand why it might work for Single Forms but not Continuous ones.

You may want to consider Conditional Formatting to manage showing each record correctly. That wouldn't require code to update every time you move between records.

BTW, your routine can be considerably simplified to :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     Me.lblActive.Visible = Me.Active
  3.     Me.lblInactive.Visible = (Not Me.Active)
  4. End Sub
Jun 11 '23 #3
ezappsrUS
3 2Bits
Thanks for the tips. Question is solved.
Jun 12 '23 #4
NeoPa
32,556 Expert Mod 16PB
Very pleased to hear it :-)

Always nice when an OP (Opening Poster / Creator of Thread) replies & confirms their question is resolved.
Jun 13 '23 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
1
by: irene | last post by:
Hi, I am trying to update the checkbox value in a datagrid. I am using TemplateColumn to add the checkbox to the datagrid and it is showing correct data from the database now. Ideally, the end user...
3
by: Julius Fenata | last post by:
Dear all, I have checkbox on my webform, and I want that when I click my checkbox, it should change status between true or false... Here is my code, // Code Behind CheckBox1.Attributes =...
1
by: Art | last post by:
Hi, I have a problem with checkbox value on the page connected to MS Access. Ms Access field is: Independent - Data Type: Yes/No My code is: <form name="form" method="post"...
11
by: manjunath1985 | last post by:
Hi, I am really having problem in checkbox.... i have a php page which displays the username retrieved from the database i want to create a checkbox for each username and pass the selected...
2
by: palanidharma | last post by:
hi, i writing the code for selectd check box value deleted.but the code not working <?php include("conn.php"); $sel= mysql_select_db("sangoma"); //include("function.php"); ?>
10
by: k3pp0 | last post by:
Hello. Here's my example form: <form method="get" action=""> <p> <input type="radio" name="radio_example" id="radio1" value="radio1_val" /> <label for="radio1">radio button one</label> </p>
5
by: ndeeley | last post by:
Hi, This is driving me mad - can someone guide me in the right direction please? I am outputting the results of a query to a webpage - in this case drawings in a database. The user selects the...
0
by: safuta | last post by:
i need help here. how do i display checkbox value from my database MS access in a visual basic 6 form? i hv 2 checkbox in my form, which are Available and Not Available. if the value is yes, i want...
0
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...
0
isladogs
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...
0
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.