Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Accessing a Collection within a Class

Posted on 2001-08-16
4
Medium Priority
?
182 Views
Last Modified: 2010-05-02
I have created two classes, one called Order and the other called LineItem. The Order class has a Collection in it of type LineItem. I am writing a method in my Order class to populate the Order object and the lineitem collection based on the order info in a database. However, I do not know how to access the lineitems from within this method. I have tried using the lineitem.add but I get an error. It would seem pointless to do a seperate Lineitem method to populate that, but it seems to be the only option unless I can figure out how to do it within the method of my Order object/class.

Any help would be appreciated!

Thanks.
0
Comment
Question by:kriskramer
4 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 400 total points
ID: 6394348
declare the method as public
0
 
LVL 2

Expert Comment

by:BozzoCage
ID: 6394803
If I properly undersood:

class LineItem
  private p_linedata as string
  public sub SetData(l as string)
     p_linedata = l
  end sub

class Orders
  private p_item as Collection
  public sub class_initialize
    set p_item=new Collection
  end sub
  public sub Populate
    dim l as new LineItem
    l.SetData (rst("name"))
    p_item.Add l
  end sub
  public function GetLineData(lineNo as long)
    GetLineData = p_item(lineNo)
  end function
 
------

Read code and ask if something is unclear.

Regards,
  BozzoCage  
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7202339
Hi kriskramer,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept bobbit31's comment(s) as an answer.

kriskramer, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7215951
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question