Using Smart Tags with VBA (1 Viewer)

shuffine@hcreit.com

Registered User.
Local time
Today, 15:10
Joined
Dec 18, 2013
Messages
19
Access 2007-2010 format
Form, 9 bound fields, grouped together Smart Tag = "UnitGroup"
Summary: Needing to run VBA whenever the value is changed within one (or more) of these fields. User could be placing new value (defaults at 0) or editing(changing) previous value entered.

I am not good on writing loops/next statements. But I am wanting to make an image visible to true when someone changes the value within the group.

This is what I have so far:

Dim ctlGroup as Control

For Each ctlGroup in Me.Controls
If ctlGroup.Tag = "UnitGroup" Then 'finds the smart tagged controls
If ctlGroup Then 'if any fields within group changes value then
Me.Image321.Visible = True 'show image
End if
End If
Next ctlGroup

I don't even know if I am close with my code - clearly it is not complete and lots of holes of wonderment!! Maybe it would be easier just to use the individual even (on change) with each individual field (9).

I am really hoping someone can help me! I greatly appreciate it!! :banghead:

Thank you!
 

Estuardo

Registered User.
Local time
Today, 20:10
Joined
May 27, 2003
Messages
134
G'd evening,
Is not clear to me what are you're after.
I don't see the need to loop through all form's controls when afterupdate/dirty/change and several others may work for you.

In a normal context you will need an event for each one of the controls that belong to the UnitGroup. What you don't need is to repeat code. Take a look at this:
Code:
Private Sub txtUni1_AfterUpdate()
     Call ShowImage
End Sub
Private Sub txtUni2_AfterUpdate()
     Call ShowImage
End Sub
Private Sub txtUni3_AfterUpdate()
     Call ShowImage
End Sub
Private Sub txtUni4_AfterUpdate()
     Call ShowImage
End Sub
'
'
'
Private Sub txtUni9_AfterUpdate()
     Call ShowImage
End Sub


Private sub ShowImage()
   Me.Image321.Visible = True
End sub

This will be easier and faster than a loop.
 

shuffine@hcreit.com

Registered User.
Local time
Today, 15:10
Joined
Dec 18, 2013
Messages
19
Thank you Estuardo. The situation actually changed, so I am all set now. I appreciate your help! You actually helped me see how to use the call function.
 

Users who are viewing this thread

Top Bottom