473,569 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How To Pass A Collection To A FUNCTION ??? (Access 2000) Sample Code Included

Hi All,

I am trying to Pass A Collection To A FUNCTION ??? (Access 2000)

I have a Class called BO (for Business Objects)

Within BO I have a Function called ShowCollection

Public Sub showcollection( colCollection As Collection)
MsgBox "colCollection( 2)=" & colCollection(2 )
End Sub

I've tries a whole number of ways and its not working?

The calling code is :-

Dim oCollection As New Collection
oCollection.aaa = "aaa"
oCollection.aaa = "BBB"
oCollection.aaa = "CCC"

Dim oBO As New BO
oBO.showcollect ion(oBO)

Any IDEA ???
Many Thanks In Advance ...

Regards

Mark Dicken
England, UK
(Currently Working in Saudi Arabia)
Nov 12 '05 #1
5 7465
rkc

"Mark Dicken" <ma***@training serve.com> wrote in message
news:3b******** *************** **@posting.goog le.com...
Hi All,

I am trying to Pass A Collection To A FUNCTION ??? (Access 2000)

I have a Class called BO (for Business Objects)

Within BO I have a Function called ShowCollection

Public Sub showcollection( colCollection As Collection)
MsgBox "colCollection( 2)=" & colCollection(2 )
End Sub

I've tries a whole number of ways and its not working?

The calling code is :-

Dim oCollection As New Collection
oCollection.aaa = "aaa"
oCollection.aaa = "BBB"
oCollection.aaa = "CCC"

Dim oBO As New BO
oBO.showcollect ion(oBO)

Any IDEA ???
Many Thanks In Advance ...


If the Sub showcollection sub is a method of your BO class and
oCollection is a member of your BO class you do not need to pass
oCollection as a parameter to the sub. Delete the
colCollection As Collection argument from the sub declaration and
it should work as expected.

Nov 12 '05 #2
RKC,

Thanks for the reply, that DOES makes sense. (BUT)...

The calling code is from a FORM Module and is not part of the BO
(Business Object) Class, in this sort of case the Forms can be viewed
as the PL (Presentation Layer) and what I'm trying to achieve is a
little OO and abstration... Any ideas on how I can simply have the
ability to say send in a COLLECTION of say orders and get an array
back of the orders not yet fullfilled - for example ???

Many Thanks In Advance ...

Regards

Mark Dicken
Nov 12 '05 #3
rkc

"Mark Dicken" <ma***@training serve.com> wrote in message
news:3b******** *************** **@posting.goog le.com...
RKC,

Thanks for the reply, that DOES makes sense. (BUT)...

The calling code is from a FORM Module and is not part of the BO
(Business Object) Class, in this sort of case the Forms can be viewed
as the PL (Presentation Layer) and what I'm trying to achieve is a
little OO and abstration... Any ideas on how I can simply have the
ability to say send in a COLLECTION of say orders and get an array
back of the orders not yet fullfilled - for example ???

The following class and sample procedure shows how to pass a collection
to a class, set a class property to that collection and then call a method
to read back all the members of the collection. I'd need details to be
any more specific than that.

<Class1>
Private colOrders As VBA.Collection

Public Property Set Orders(c As VBA.Collection)
Set colOrders = c
End Property

Public Sub ShowCollection( )
Dim i As Integer
Dim s As String

For i = 1 To colOrders.Count
s = s & colOrders(i) & vbCrLf
Next

MsgBox s
End Sub

</Class1>
<Calling procedure>

Sub useClass1()
Dim c1 As Class1
Dim c As New VBA.Collection

Set c1 = New Class1

c.Add "Muffins"
c.Add "Bagels"
c.Add "Fried Cakes"

Set c1.Orders = c
c1.ShowCollecti on

Set c1 = Nothing

End Sub

</Calling procedure>
Nov 12 '05 #4


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
Thanks RKC,

That CODE SNIPPET was GREAT.

Actually it was better than what I was expecting ...

Because it is set via a Property.

Cheers Dude.

Regards

Mark Dicken
http://www.MarkDicken.com
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #6

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

Similar topics

5
2716
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use the appointment collection to populate the calendar control. The performance getting the XML data is fine, but loading the data into the collection...
1
7658
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into the bottom of this email)
4
11968
by: deko | last post by:
This is a basic program flow question. I'm trying to refractor an AC2000 app and split sections of code into separate modules. But there are a number of collections I create in one big module - containing file paths, Excel worksheet names, etc - I'm not sure how to pass these around, or if I'd be better off saving things to a table and...
0
3308
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems appear when someone is trying to use it as front-end for real server database systems such as PostgreSQL or MySQL. One of these problems is regarding...
18
5909
by: jimfortune | last post by:
I have an A97 module called modWorkdayFunctions in: http://www.oakland.edu/~fortune/WorkdayFunctions.zip It allows the counting of workdays taking into consideration up to 11 U.S. holidays. More holidays can be added easily. Also, there is a boolean flag for including or excluding Saturdays or Sundays as part of the work week. The only...
5
2269
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a collection object -- say, a dictionary. Populating that collection object with custom objects, say, Person. What I really want to see is how to...
11
6612
by: Yelena Varshal via AccessMonster.com | last post by:
Hello, I have a problem with one of msaccess.exe API calls that work on my desctop but does not work on the laptop from within MS ACCESS. There is a lot of differences between 2 computers including one running Office 2000 and another running Office 2003. This code was created by a previous developer. I need to find the description and...
6
5955
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few forms in the database that will use this function, so I need to be able to tell the code which form to unlock. What I have is as follows: Public...
12
3000
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope. The global variables and global functions are hidden to prevent from accessing by the programmers. All global functions share global variables....
0
7694
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...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
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. ...
1
7666
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...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5504
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...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
936
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...

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.