I Can't Tag

chuckster

Registered User.
Local time
Today, 14:11
Joined
Oct 4, 2000
Messages
52
Chris RR was kind enought to introduce me to the concept of tags but I'm not clear on how to use them.

**Details of what I'm trying to do.**

Forms name is frmBulkOrderForm

I have 10 Text Boxs named RowTot1, RowTot2 etc. They all have the same tag name "tagRowTotal".

I basically want some code that will make the RowTotx field invisible if it equals 0.


Thanks.
 
The code below will hopefully get you on your way... As I am also relatively new to access I am unsure of how to include all the RowTos in the If statement, but I am sure someone else will come and fill in what I have left out.

Private Sub Form_Current()
Dim frmMyForm As Form
Dim ctlMyCtls As Control
Dim counts
Set frmMyForm = Forms!nameofform

If RowTot1 = 0 Then
For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "tagrowtotal" Then
ctlMyCtls.Visible = False
End If
Next ctlMyCtls
Else
For Each ctlMyCtls In frmMyForm.Controls
If ctlMyCtls.Tag = "tagrowtotal" Then
ctlMyCtls.Visible = True
End If
Next ctlMyCtls
End If
End Sub

HTH
 
The code looks good to me, although if I'm toggling the visible property, I'll also usually toggle enabled/disabled, too.

This code will cycle through any & all fields in the form that have the same value in their tag. Where you put the code in your form will depend on just when you want to modify the fields.

Remember that you need to change the "Tag" property for the screen fields themselves, before the code will work. And you might want to cut-and-paste the value, it's in retyping it that I usually mess up. And you can have different groups of tags in the same form (no, I don't know how many...)
 
Cheers for that. But what I was hoping to learn was an easy way to check a group of controls but check them individually.

If control1 = 0 and tag = "tagrowtotal" then visible = false

If control2 = 0 and tag = "tagrowtotal" then visible = false

But without referencing each specific controls name.


Cheers.
 
Hi Chackster

You can try smt like:

Public Sub test_text()
Dim ctl As Access.Control
For Each ctl In Me.Controls
If TypeOf ctl Is Access.TextBox Then
If ctl.Tag = "tagRowTotal" Then
ctl.Visible = CBool(ctl.Value)
End If
End If
Next txt
End Sub

kaspi
 

Users who are viewing this thread

Back
Top Bottom