473,749 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("FullNa me", "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 2004
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("FullNa me", "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******** ***********@twi ster.nyroc.rr.c om...
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("FullNa me", "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******** ***********@twi ster.nyroc.rr.c om...
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("FullNa me", "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="Fo rmColour=Red;Fo rmCaption=Hello ;FormMode=ReadO nly"
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 "FormCaptio n", "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("For mCaption") Then
Me.Caption=kvs. Item("FormCapti on").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("For mCaption") 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.ne t> wrote in message
news:Kt******** ********@fe06.l ga...
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
2435
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 respective files / folders etc. Nevertheless, I get the following error when I start my application: Compile error; Sub or Function not defined
1
1844
by: Chris | last post by:
Hi all ! I need to find a good tutorial about VBA and Access. Thanks
2
1866
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. One subform (course occurrence) has got 4 subforms of its own, another subform (course web description) has got 1. The main form has got navigation buttons, occurrence subform has got navigation buttons (there can be several occurrences of the...
5
7864
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 need to send it to them? 2) I have a function to fill a table with values, that store the page and column numbers of a display of staff members. I had him check the link to Microsoft DAO 3.6 Object Library under references, but it still won't...
3
2244
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 beginners? I was looking at "Beginning Access 2002 VBA" by Dave Sussman however many of the reviews are not so flattering about this one. Any recommendations are much appreciated.
5
2423
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 tutorial sites that will help me learn how to use Access XP? I hope you can help. I appreciate any help or information given.
2
3675
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 Developer's Handbook" and that's what I've decided to do. What I'd like to know is, which version of the book should I get. I am working in Access 2000, but I don't want to limit myself to that, I would like a wider range of knowledge so I can easily...
52
9980
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 2005, and, since he already has licenses for Office Pro 2002, he wants to upgrade to that. I've been saying that we need to upgrade to Access 2003, not 2002, even if Office is kept at 2002. We are also looking to do a fair amount of...
4
3795
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 several back end files. When I first dropped in the function I was getting an error on one of my tables saying "Couldn't relink table, table doesn't exist"... or
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9566
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8256
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.