LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default How can I make a simple database.

I think you are missing a line in your loop:

Dim MyRecord as Record
For Each Cell in Selection
Set MyRecord = New Record ' << missing line
MyRecord.OrdernNmber = Cell.Value
MyCollection.Add MyRecord
Next

--

Rob wrote in message ...
I've made a class module and I'm tring to add my objects to a collection, but I can't seem to get the code right. I've set up my class module like below, and in my sub I want to loop through a list of order numbers and add one of my class module records to my collection. The problem is that only one record gets stored, multiple times.

Thanks for any help
Rob

'Class Module "Record" Code
Public OrderNumber as long

Function OrderDate() As Date
OrderDate = FetchOrderDate(OrderNumber)
End Function

Function DeliveryDate() As Date
DeliveryDate = FetchDeliveryDate(OrderNumber)
End Function
'End of Class Module "Record" Code

'Module Code
Sub StoreRecords
Dim MyCollection as New Collection
Dim MyRecord as Record
For Each Cell in Selection
MyRecord.OrdernNmber = Cell.Value
MyCollection.Add MyRecord
Next

'now I test whether it worked by getting it to tell me the order numbers stored
For Each Record in MyCollection
MsgBox Record.OrderNumber
Next

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
complex & simple database on a single form Merche Excel Discussion (Misc queries) 2 May 4th 07 04:46 PM
How to make reference to database and if true copy from database? V!p3r Excel Discussion (Misc queries) 4 February 5th 07 02:19 PM
Make it more simple or intuitive to do simple things Vernie Charts and Charting in Excel 1 March 16th 05 04:01 AM
How can I use Excel as a simple database for Quoting? Stefan Excel Discussion (Misc queries) 1 January 4th 05 01:26 PM
Maintaining a simple database Stuart[_5_] Excel Programming 0 September 30th 03 08:47 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"