CheckBox to hide adjacent textbox on a Continuous form (1 Viewer)

Gint3232

Registered User.
Local time
Today, 21:54
Joined
Jan 30, 2018
Messages
20
I have form that has a textbox that overlays another Textbox, I am attempting to hide one textbox and make the other visible depending on the checkboxs value = "True" or "False" . I have placed my code on the afterupdate event, but the issue I am having if I click the checkbox on any row , then all textboxs either hide or are visible, I only wish for the relevant record to hide and not all textbox records. Can anybody suggest or explain how to do this if its possible?
So far the code which I thought would work (silly me) is as follows:
Code:
If Me.check_box = True Then

Me![box_OverLay].Visible = True
Me![ShiftAbrevation].Visible = False
Refresh

Else

Me![box_OverLay].Visible = False
Me![ShiftAbrevation].Visible = True
Refresh

End If
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:54
Joined
May 7, 2009
Messages
19,230
You cant do that on contonuous form.

Conditiinal fornatting can only make that textbox appear as if it is invisible.
If the ckbox is not bound then all chkbox will be tck/ untick.

If it is bound create a cf that will make the forefriund of the text white
 

Gint3232

Registered User.
Local time
Today, 21:54
Joined
Jan 30, 2018
Messages
20
You cant do that on continuous form.

Conditional formatting can only make that textbox appear as if it is invisible.
If the ckbox is not bound then all ckbox will be tick/ untick. If it is bound create a cf that will make the forefront of the text white
thanks for your suggestion, The thing is my checkbox is bound and therefore acts as it should do, the issue I am having as I said in my O/P is that all textboxs(which are also bound) either get hidden or become visible, when I use my code which runs off the checkbox.event, which doesn't really make sense. Can anyone help please
 

Mark_

Longboard on the internet
Local time
Today, 06:54
Joined
Sep 12, 2017
Messages
2,111
Continuous forms do not work like normal forms. In some cases they treat each instance of the form as a separate form (when there is bound data) but other times they treat ALL instances as the same form (for control positions, visibility, font, what not).

From what I gather, you have two different text fields you want to allow entry into, but conditionally. From a design perspective, why would you need two different entries if you are using a check box to distinguish them?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:54
Joined
Feb 19, 2002
Messages
43,257
Continuous forms do not work like normal forms.
Actually they work exactly the same way that single forms work. The difference is that since Access only maintains a single form instance in memory, all instances of the continuous form show the same properties. Therefore, if you hide a control, it is hidden on ALL rows. If you have an unbound control, it shows exactly the same value on all rows.

Depending on what your background is, you might be able to use conditional formatting to set the font color to be the same as the background color so the control will disappear. Of course you won't be able to use borders because you probably won't be able to control those with Conditional formatting. Conditional formatting is great as far as it goes but there is a limit to what it can do for you. The other issue with Conditional formatting is that MS has never updated the color palette to match the form's Theme so it is impossible to make Conditional formatting seamless when you are using themes.
 

Gint3232

Registered User.
Local time
Today, 21:54
Joined
Jan 30, 2018
Messages
20
From what I gather, you have two different text fields you want to allow entry into, but conditionally. From a design perspective, why would you need two different entries if you are using a check box to distinguish them?

Thanks, What I am attempting to achieve is : If a user clicks a checkbox then I wish to prevent access to an adjacent (other)textbox, by means of not visible by either hiding it or setting just that Text (not all of them to not for editing) or alternatively overlaying the textbox so it appears gone. But what I really would prefer though is something similar to a strike-through affect, but from what I googled thats also not available in access, so truly this is my second choice, but from what you say this is also not an option!
 

Gint3232

Registered User.
Local time
Today, 21:54
Joined
Jan 30, 2018
Messages
20
you might be able to use conditional formatting to set the font color to be the same as the background color so the control will disappear..
Just a thought, is it possible to programmatically send a text box to the front or back or will the same thing happen again and all instances will go to the back or front?
 

Mark_

Longboard on the internet
Local time
Today, 06:54
Joined
Sep 12, 2017
Messages
2,111
@Pat,

I they DID work the same, why can't you move a control around on a continuous form? Try setting the .Width for a label to see what I mean.

@OP, So there are not two text boxes on the same form? Do you really want to enable/disable one text box depending on the value of a checkbox?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:54
Joined
Feb 19, 2002
Messages
43,257
The problem is with "visible" properties. You can certainly lock controls to prevent entry. That doesn't change the way they look so even though every instance is locked, you won't notice since all that actually matters is what is in the current row. However, this goes further than locking the control based on the change in a checkbox. In order to work for existing records, the code also needs to run in the form's Current event. So create a little sub and call the sub from the AfterUpdate event of the checkbox and also from the Current event.

Code:
private setlocked()
  If Me.somecheckbox = True Then
      Me.fld1.Locked = True
      Me.fld2.Locked = True
      Me.fld3.Locked = True
  Else
      Me.fld1.Locked = False
      Me.fld2.Locked = False
      Me.fld3.Locked = False
End If
End Sub
 

Gint3232

Registered User.
Local time
Today, 21:54
Joined
Jan 30, 2018
Messages
20
The problem is with "visible" properties. You can certainly lock controls to prevent entry. That doesn't change the way they look so even though every instance is locked, you won't notice since all that actually matters is what is in the current row. However, this goes further than locking the control based on the change in a checkbox. In order to work for existing records, the code also needs to run in the form's Current event. So create a little sub and call the sub from the AfterUpdate event of the checkbox and also from the Current event.

Code:
private setlocked()
  If Me.somecheckbox = True Then
      Me.fld1.Locked = True
      Me.fld2.Locked = True
      Me.fld3.Locked = True
  Else
      Me.fld1.Locked = False
      Me.fld2.Locked = False
      Me.fld3.Locked = False
End If
End Sub
Thanks for that, Also, will this work for locking combo boxs as well, or ?
 

Gint3232

Registered User.
Local time
Today, 21:54
Joined
Jan 30, 2018
Messages
20
@Pat,

I they DID work the same, why can't you move a control around on a continuous form? Try setting the .Width for a label to see what I mean.

@OP, So there are not two text boxes on the same form? Do you really want to enable/disable one text box depending on the value of a checkbox?

So sorry, but you've lost me, I am not sure what your asking me, I only have two textboxs one is solely for hiding the other in order to prevent access/entry to it. Other than that it would not be on the form, if that helps explain things!

Thanks
 

Mark_

Longboard on the internet
Local time
Today, 06:54
Joined
Sep 12, 2017
Messages
2,111
Ah, that clears it up.

Pat's code will work just fine and you won't need a second text box. What is in the field will still show up, but the user won't be able to make changes. Yes, it will work for combo boxes as well.
 

isladogs

MVP / VIP
Local time
Today, 14:54
Joined
Jan 14, 2017
Messages
18,211
One thing that you may find useful is to change the control back colour when the control is locked. This serves as a visual reminder
 

Users who are viewing this thread

Top Bottom