vba code to turn on test boxes

Tupacmoche

Registered User.
Local time
Today, 14:57
Joined
Apr 28, 2008
Messages
291
Hi Form Masters,

I have several unbound text boxes that I have placed underneath several other textboxes. The ones underneath have the code ChrW("&H2714") which is the symbol for a check Mark as there Default Value. They all have there Visible method set to False (so they are invisible). The point is that as a user enters values into the textbox above them the check becomes visible since data has been entered. Here is the code that I put into the On Current event of the form:

'Turn on check marks.
If Nz(Len(Me.txtWriter.Value)) > 1 Or Nz(Len(Me.Draft_Date.Value)) > 1 Or Nz(Len(Me.DEC_Review_1.Value)) > 1 _
Or Nz(Len(Me.GO_Review.Value)) > 1 Or Nz(Len(Me.DEC_Review_2.Value)) > 1 Or Nz(Len(Me.GYK_Review.Value)) > 1 _
Or Nz(Len(Me.Signed_Mailed.Value)) > 1 Then
Me.TxtW.Visible = True
Me.TxtDD.Visible = True
Me.TxtDR1.Visible = True
Me.TxtGR.Visible = True
Me.TxtDR2.Visible = True
Me.TxtGYK.Visible = True
Me.TxtSC.Visible = True
Me.Refresh
Else
End If

It simple checks that there is something in the textbox and turns it on. Otherwise it should stay off. But they stay on all the time. Can anyone see what, I doing wrong?:eek:
 
here's an example using a loop and the controls tag property.
 

Attachments

Uncle Gizmo,

To answer your questions, I want the 'check' in the textbox to turn off if the corresponding textbox above it is empty. So the code Nz(Len(Me.txtWriter.Value)) > 1 checks to see if the string is greater than one and if it is the check is turned on otherwise it stays off. As, I navigate from record to record, I want the check to turn on or off based on data being entered into the corresponding textbox. This is like the UPS (United Postal Service) page that shows the progress of a package.
 
Uncle Gizmo,

Nice video UG but what if you have dozens of controls of all sorts on a form how do you loop through a set of 10?
 
let's say you were already using Tag property for something else
In addition to UG's suggestions you can also use instr() with the tag.
for instance a tag like - Req NL AA
Code:
If InStr(1, ctl.Tag, "Req") Then ...

If InStr(1, ctl.Tag, "AA") Then ...
 
@Tupacmoche
Just reinforcing the idea of how useful the tag property is for controlling the state of a group of controls, have a look at my example database here https://www.access-programmers.co.uk/forums/showthread.php?t=293439

Unlike Tony, I chose to use code in a standard module so you have a choice of methods.

@Moke
I'd never thought of using ctl.Tag in an Instr expression. Thanks. That could be useful
 

Users who are viewing this thread

Back
Top Bottom