473,395 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Access Developer's Handbook 2002: Tagged Values

Hi Newsgroup!

I know many of you must have bought the Access Developer's Handbook and used
the Tagged Values class, so perhaps I can ask someone to check something.
On page 303, it describes the Add method of the class, and claims it returns
the TaggedValue item that was added. However, as far as I can see, it does
not provide a return value (despite being a function rather than a sub) so
cannot work as advertised.

Am I right in my assumption?

Is there any point in a function - why not a sub? The TaggedValue class is
so simple (just two properties) that I wonder whether anyone would need:
Set tv = tvs.Add("FullName", "Brian Wilson")
Since there isn't much you could do with the tv object afterwards.

Finally, if I did want to make it work as advertised, would I just add this
as the final line of code?
Set Add = tv
Here is the code in question:

Public Function Add(Tag As String, _
Value As String) As TaggedValue
Dim tv As TaggedValue

' If the tag already exists, remove
' it so you can set the new value.
Call Remove(Tag)

' Create the new TaggedValue object, set its
' properties, and add it to the collection.
Set tv = New TaggedValue
tv.Tag = Tag
tv.Value = Value
mcolItems.Add tv, Tag
End Function
Nov 13 '05 #1
4 1988
rkc
Brian Wilson wrote:
I know many of you must have bought the Access Developer's Handbook and used
the Tagged Values class, so perhaps I can ask someone to check something.
On page 303, it describes the Add method of the class, and claims it returns
the TaggedValue item that was added. However, as far as I can see, it does
not provide a return value (despite being a function rather than a sub) so
cannot work as advertised.

Am I right in my assumption?

Is there any point in a function - why not a sub? The TaggedValue class is
so simple (just two properties) that I wonder whether anyone would need:
Set tv = tvs.Add("FullName", "Brian Wilson")
Since there isn't much you could do with the tv object afterwards.

Finally, if I did want to make it work as advertised, would I just add this
as the final line of code?
Set Add = tv
Here is the code in question:

Public Function Add(Tag As String, _
Value As String) As TaggedValue
Dim tv As TaggedValue

' If the tag already exists, remove
' it so you can set the new value.
Call Remove(Tag)

' Create the new TaggedValue object, set its
' properties, and add it to the collection.
Set tv = New TaggedValue
tv.Tag = Tag
tv.Value = Value
mcolItems.Add tv, Tag
End Function


I have never owned a copy of the Developer's Handbook so I am not
familiar with the full context of that function. With that said, you
are correct that in order for the function to actually return anything
you would have to set Add = tv.

It looks like the actual purpose of the procedure is to add a tv object
to the mcolItems collection that is defined some where else. Like you
it baffles me why a taggedvalue object is even needed since on the
surface it doesn't appear to add any capability that isn't already
available with a VBA.Collections value and key parameters.



Nov 13 '05 #2
Is this part of a class module? if so it may be that they are using it to
create a collection ie list of items of this class kinda like a record set.
but with a lot more power. it may work like this you create a class that
defines your data propeties next you create a class with a data type as
collection of your class. now you can work with your objects as if they were
one item example you have a class called employee and another called
timecard yo may want to create a timesheet of all employees time card
records. in this case the timesheet is your collection, and the classes
employee and timecard are your object. I hope this helps.


"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:w3*******************@twister.nyroc.rr.com...
Brian Wilson wrote:
I know many of you must have bought the Access Developer's Handbook and
used the Tagged Values class, so perhaps I can ask someone to check
something. On page 303, it describes the Add method of the class, and
claims it returns the TaggedValue item that was added. However, as far
as I can see, it does not provide a return value (despite being a
function rather than a sub) so cannot work as advertised.

Am I right in my assumption?

Is there any point in a function - why not a sub? The TaggedValue class
is so simple (just two properties) that I wonder whether anyone would
need:
Set tv = tvs.Add("FullName", "Brian Wilson")
Since there isn't much you could do with the tv object afterwards.

Finally, if I did want to make it work as advertised, would I just add
this as the final line of code?
Set Add = tv
Here is the code in question:

Public Function Add(Tag As String, _
Value As String) As TaggedValue
Dim tv As TaggedValue

' If the tag already exists, remove
' it so you can set the new value.
Call Remove(Tag)

' Create the new TaggedValue object, set its
' properties, and add it to the collection.
Set tv = New TaggedValue
tv.Tag = Tag
tv.Value = Value
mcolItems.Add tv, Tag
End Function


I have never owned a copy of the Developer's Handbook so I am not
familiar with the full context of that function. With that said, you
are correct that in order for the function to actually return anything
you would have to set Add = tv.

It looks like the actual purpose of the procedure is to add a tv object
to the mcolItems collection that is defined some where else. Like you
it baffles me why a taggedvalue object is even needed since on the surface
it doesn't appear to add any capability that isn't already
available with a VBA.Collections value and key parameters.



Nov 13 '05 #3
"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:w3*******************@twister.nyroc.rr.com...
Brian Wilson wrote:
I know many of you must have bought the Access Developer's Handbook and
used the Tagged Values class, so perhaps I can ask someone to check
something. On page 303, it describes the Add method of the class, and
claims it returns the TaggedValue item that was added. However, as far
as I can see, it does not provide a return value (despite being a
function rather than a sub) so cannot work as advertised.

Am I right in my assumption?

Is there any point in a function - why not a sub? The TaggedValue class
is so simple (just two properties) that I wonder whether anyone would
need:
Set tv = tvs.Add("FullName", "Brian Wilson")
Since there isn't much you could do with the tv object afterwards.

Finally, if I did want to make it work as advertised, would I just add
this as the final line of code?
Set Add = tv
Here is the code in question:

Public Function Add(Tag As String, _
Value As String) As TaggedValue
Dim tv As TaggedValue

' If the tag already exists, remove
' it so you can set the new value.
Call Remove(Tag)

' Create the new TaggedValue object, set its
' properties, and add it to the collection.
Set tv = New TaggedValue
tv.Tag = Tag
tv.Value = Value
mcolItems.Add tv, Tag
End Function


I have never owned a copy of the Developer's Handbook so I am not
familiar with the full context of that function. With that said, you
are correct that in order for the function to actually return anything
you would have to set Add = tv.

It looks like the actual purpose of the procedure is to add a tv object
to the mcolItems collection that is defined some where else. Like you
it baffles me why a taggedvalue object is even needed since on the surface
it doesn't appear to add any capability that isn't already
available with a VBA.Collections value and key parameters.

Thanks for that (and I hope you won't be too dissapointed to learn I am not
the Brian Wilson of Beach Boys fame).

The general idea is to provide a structured way to build up paired values
which might be useful for many things, but one specific example is passing
multiple values to forms.

Without any class coding, you might typically write:

Dim strOpenArgs As String
strOpenArgs="FormColour=Red;FormCaption=Hello;Form Mode=ReadOnly"
DoCmd.OpenForm "frmMyForm", , , , , acDialog, strOpenArgs

Then in the form's open event, you write code to parse these parameters and
do something useful with them.
Using these tagged values (or KeyValues as my re-write will call them), you
could do something like:

Dim kvs As KeyValues
Set kvs = New KeyValues
kvs.Add "FormColour", "Red"
kvs.Add "FormCaption", "Hello"
kvs.Add "FormMode", "ReadOnly"
DoCmd.OpenForm "frmTest", , , , , acDialog, kvs.Text
' Code in the form's open event
Dim kvs As KeyValues
Dim kv As KeyValue
Dim strOpenArgs As String

strOpenArgs = Nz(Me.OpenArgs, "")

If Len(strOpenArgs) > 0 Then
Set kvs = New KeyValues
kvs.Text = strOpenArgs
If kvs.Exists("FormCaption") Then
Me.Caption=kvs.Item("FormCaption").Value
End If
...
etc
...
Set kvs = Nothing
End If

You can see it does pretty much the same thing, but allows a more structured
approach and allows
If kvs.Exists("FormCaption") Then ...
To check whether I've passed a particular parameter to a form in the
openargs

Anyway, I wonder if other people have any better ways to do this - but I
might post a new subject for this.
Nov 13 '05 #4
"AL FINK" <ex****************@charter.net> wrote in message
news:Kt****************@fe06.lga...
Is this part of a class module? if so it may be that they are using it to
create a collection ie list of items of this class kinda like a record
set. but with a lot more power. it may work like this you create a class
that defines your data propeties next you create a class with a data type
as collection of your class. now you can work with your objects as if they
were one item example you have a class called employee and another called
timecard yo may want to create a timesheet of all employees time card
records. in this case the timesheet is your collection, and the classes
employee and timecard are your object. I hope this helps.

Hi
Thanks for the response. Yes - it is a part of a class module and is as you
describe. The question was not so much a general "What's going on here,
then?" but quite a specific question about the Add method not returning a
TaggedValue object. I think I can see what's happening, but I think there
is a mistake in the book. So far, however, no owner of Access Developer's
Handbook wants to check this.


Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Uttam | last post by:
Hello, I am using the code from Chapter 17 specifically the code from the font frmListFonts in my application. I have taken care to copy all the relevant modules / class modules into the...
1
by: Chris | last post by:
Hi all ! I need to find a good tutorial about VBA and Access. Thanks
2
by: Galina | last post by:
Hello I have a very complex database application, which have been working fine for several years in Access 97. Now I had to convert it into Access 2000. The main form (course) has got 2 subforms....
5
by: j.mandala | last post by:
Someone is trying to run my Access 2002 database under Access 2003. He has had a number of problems: 1) i used the MSComCt2.ocx for it's Date and Time picker. I can't find it under 2003. Do I...
3
by: Big Time | last post by:
I'm looking into buying a book to learn Access VBA programming. I am very familiar with Access however I am new to programming Access with VBA. Are there any recommendations for books for...
5
by: Neil Hindry | last post by:
I want to learn more about how to use Access XP, so I thought a tutorial might be a good idea. I searched the internet but couldn't find anything decent. Does anyone know of any free Access XP...
2
by: MyPersonalSpamBot | last post by:
Hey group, I've been working as an access developer as part of my college co-op. I am interested in learning more about Access, and I repeatedly see in this newsgroup, "Read Access XXX...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
4
by: Kelii | last post by:
Hi all, (WinXP Pro SP2, Access 2003) I'm using Dev Ashish's fRefreshLinks function from AccessWeb (http://www.mvps.org/access/tables/tbl0009.htm) to relink tables in my front end to one of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.