Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / July 2007

Tip: Looking for answers? Try searching our database.

Assigning more than one tag to tag property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
HeislerKurt@gmail.com - 05 Jul 2007 21:36 GMT
It it possible to assign more than one tag to a control's tag
property, so that you can assign it to multiple groups?

I tried separating tags by semicolons or commas but that seemed to
render each tag obsolete.

Kurt
Klatuu - 05 Jul 2007 21:50 GMT
interesting you should ask that.  I wrote a class module that manages
multiple values in tags, but I don't have it here at work.  Post back so I
can track the thread and if I can find it over the weekend, I will post back
with the code and how to use it Monday.
Signature

Dave Hargis, Microsoft Access MVP

> It it possible to assign more than one tag to a control's tag
> property, so that you can assign it to multiple groups?
[quoted text clipped - 3 lines]
>
> Kurt
Douglas J. Steele - 05 Jul 2007 23:56 GMT
Use the Split function to divide the tag into the individual component
elements.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> It it possible to assign more than one tag to a control's tag
> property, so that you can assign it to multiple groups?
[quoted text clipped - 3 lines]
>
> Kurt
HeislerKurt@gmail.com - 06 Jul 2007 01:06 GMT
> Use the Split function to divide the tag into the individual component
> elements.

Okay. Been reading up the Split function in VBA and what I found isn't
very clear to me. What I have so far gives me a "subscript out of
range error."

Below is the code in the OnCurrent event of a subform. The tag
property I'm trying to extract is the first one in the array: "**"

###

Dim ctl As Control
Dim strMyTag() As String

   strMyTag = Split(Me.Tag, ";")

   For Each ctl In Me
       If strMyTag(0) = "**" Then
           If IsNull(Me.DailyDate) Then
               ctl.Enabled = False
           Else
               ctl.Enabled = True
           End If
       End If
   Next
   Set ctl = Nothing

###

I see that some people also define the upper and lower bounds of the
tag, as in ...

Dim intI As Integer

   strMyTag = Split(Me.Tag, ";")
   For intI = 0 To UBound(strMyTag)
   Next intI

... but it's not clear to me what this is supposed to do, or if it's
even relevent in my situation.

Kurt

On Jul 5, 6:56 pm, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
> Use the Split function to divide the tag into the individual component
> elements.
[quoted text clipped - 16 lines]
>
> - Show quoted text -
Douglas J. Steele - 06 Jul 2007 11:40 GMT
Okay, each control may or may not have a series of tags, so it's the Tag for
each control on which the Split function needs to work. Then, once you've
split each tag, you need to loop through the tags and see whether the
desired tag exists in that list.

Dim ctl As Control
Dim strMyTag() As String
Dim intI As Integer

 For Each ctl In Me
   If Len(ctl.Tag & vbNullString) > 0 Then
     strMyTag = Split(ctl.Tag, ";")
     For intI = 0 To UBound(strMyTag)
       If strMyTag(intl) = "**" Then
         If IsNull(Me.DailyDate) Then
           ctl.Enabled = False
         Else
           ctl.Enabled = True
          End If
       End If
     Next intl
   End If
 Next
 Set ctl = Nothing

I do agree with David that a more robust way makes better sense. (In other
words, store the data about which control(s) belong to which group in a
table)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

>> Use the Split function to divide the tag into the individual component
>> elements.
[quoted text clipped - 62 lines]
>>
>> - Show quoted text -
HeislerKurt@gmail.com - 06 Jul 2007 19:23 GMT
Excellent. I got it working for the OnCurrent event of my subform,
frmDailyData. (Controls with a tag of "**" need to be disabled if
DailyDate is Null, so by parsing out multiple tag properties the code
works for controls with more than one tag.)

However, I'm also trying to use the split function in a global module.
The goal is to carryover data from the previous record only for
controls with a tag property of "carryover". (This feature is the
reason for the second tag.) On the BeforeInsert Event of my subform,
frmDailyData, I have this:

  Private Sub Form_BeforeInsert(Cancel As Integer)
     Call CarryOver(Me)
  End Sub

And in a separate module, I've placed the code at the end of this
thread.

Basically, I tried to wrap the carryover code between an ... If
strMyTag(intI) = "carryover" Then ... statement. But I obviously have
something wrong because data is carried over for all controls on the
subform (whether they have no tags, a tag of "**", or a tag of " * ;
carryover ". It's ignoring the If Then condition entirely.

Thanks for your continued help!

###

Sub CarryOver(frm As Form)
On Error GoTo Err_CarryOver

   ' CarryOver code from http://allenbrowne.com/ser-24a.html

   Dim rst As DAO.Recordset
   Dim ctl As Control
   Dim i As Integer
   Dim strMyTag() As String
   Dim intI As Integer

   Set rst = frm.RecordsetClone

   For Each ctl In frm
       If Len(ctl.Tag & vbNullString) > 0 Then
           strMyTag = Split(ctl.Tag, ";")
           For intI = 0 To UBound(strMyTag)
               If strMyTag(intI) = "carryover" Then
                   If rst.RecordCount > 0 Then
                       rst.MoveLast
                       For i = 0 To frm.Count - 1
                           Set ctl = frm(i)
                           If TypeOf ctl Is TextBox Then
                               If Not IsNull(rst(ctl.Name)) Then
                                   ctl = rst(ctl.Name)
                               End If
                           ElseIf TypeOf ctl Is ComboBox Then
                               If Not IsNull(rst(ctl.Name)) Then
                               ctl = rst(ctl.Name)
                               End If
                           ElseIf TypeOf ctl Is CheckBox Then
                               If Not IsNull(rst(ctl.Name)) Then
                               ctl = rst(ctl.Name)
                               End If
                           End If
                       Next
                   End If
               End If
           Next intI
       End If
   Next

   Set ctl = Nothing

Exit_CarryOver:
   Set rst = Nothing
   Exit Sub

Err_CarryOver:
   Select Case Err
   Case 2448         'Cannot assign a value
       Debug.Print "Value cannot be assigned to " & ctl.Name
       Resume Next
   Case 3265         'Name not found in this collection.
       Debug.Print "No matching field name found for " & ctl.Name
       Resume Next
   Case Else
       MsgBox "Carry-over values were not assigned, from " & ctl.Name
& _
           ". Error #" & Err.Number & ": " & Err.Description,
vbExclamation, "CarryOver()"
       Resume Exit_CarryOver
   End Select

End Sub

On Jul 6, 6:40 am, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
> Okay, each control may or may not have a series of tags, so it's the Tag for
> each control on which the Split function needs to work. Then, once you've
[quoted text clipped - 101 lines]
>
> - Show quoted text -
Douglas J. Steele - 07 Jul 2007 12:19 GMT
You already know which control(s) you want to carry over for, so you don't
have to loop through all of the controls in the form:

   Dim rst As DAO.Recordset
   Dim ctl As Control
   Dim i As Integer
   Dim strMyTag() As String
   Dim intI As Integer

   Set rst = frm.RecordsetClone

   For Each ctl In frm
       If Len(ctl.Tag & vbNullString) > 0 Then
           strMyTag = Split(ctl.Tag, ";")
           For intI = 0 To UBound(strMyTag)
               If strMyTag(intI) = "carryover" Then
                   If rst.RecordCount > 0 Then
                       rst.MoveLast
                       If TypeOf ctl Is TextBox Then
                           If Not IsNull(rst(ctl.Name)) Then
                               ctl = rst(ctl.Name)
                           End If
                       ElseIf TypeOf ctl Is ComboBox Then
                           If Not IsNull(rst(ctl.Name)) Then
                               ctl = rst(ctl.Name)
                           End If
                       ElseIf TypeOf ctl Is CheckBox Then
                           If Not IsNull(rst(ctl.Name)) Then
                               ctl = rst(ctl.Name)
                           End If
                       End If
                   End If
               End If
           Next intI
       End If
   Next

   Set ctl = Nothing

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Excellent. I got it working for the OnCurrent event of my subform,
> frmDailyData. (Controls with a tag of "**" need to be disabled if
[quoted text clipped - 199 lines]
>>
>> - Show quoted text -
David W. Fenton - 06 Jul 2007 00:38 GMT
> It it possible to assign more than one tag to a control's tag
> property, so that you can assign it to multiple groups?
>
> I tried separating tags by semicolons or commas but that seemed to
> render each tag obsolete.

The Access Developer's Handbook has code for this.

But I question the value.

It seems to me that you need a more robust method of storing the
information about your controls than the simple Tag property.

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

Klatuu - 06 Jul 2007 17:14 GMT
Actually, I find it very valuable; however, I would be interested in an
alternative if you have a suggestion.

The way I handle it is with a class module.  I separate the name of the tag
property from it's value with a pipe | and the combinations with ;
Then when the Class is instansiated for a form, I read the data into arrays
and expose properties that allow the developer to read, write, create, and
delete the tag values.
Signature

Dave Hargis, Microsoft Access MVP

> > It it possible to assign more than one tag to a control's tag
> > property, so that you can assign it to multiple groups?
[quoted text clipped - 8 lines]
> It seems to me that you need a more robust method of storing the
> information about your controls than the simple Tag property.
David W. Fenton - 06 Jul 2007 21:28 GMT
> Actually, I find it very valuable; however, I would be interested
> in an alternative if you have a suggestion.

Data stored in tables.

> The way I handle it is with a class module.  I separate the name
> of the tag property from it's value with a pipe | and the
> combinations with ; Then when the Class is instansiated for a
> form, I read the data into arrays and expose properties that allow
> the developer to read, write, create, and delete the tag values.

That's the ADH method.

Signature

David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.