doulostheou
Registered User.
- Local time
- Today, 09:28
- Joined
- Feb 8, 2002
- Messages
- 314
I have dabbled in object oriented programming in the past but not much. My database is getting quite complicated, so I thought I would begin to implement it to keep things from getting too cumbersome when future changes are necessary.
I have created a Vendor object, which when initialized will pull pertinent stats concerning my various vendors. I have added several properties that will return the results of more complex calculations if their values are not already set.
I can now create and destroy a Vendor object, obtaining the pertinent information I need, in about 235 miliseconds.
This is where I get lost using the object oriented approach. I now need to create vendor objects for each vendor in a pre-defined subset, sort the information, and display it back to the user.
First, I am a little shaky on creating and working with a collection of objects, but I think I can work through that.
My real problem is that with the exception of creating a temp table to store the retrieved information (which doesn't seem preferable in a multiuser environment), I cannot think of a good way to display the data back to the user. I basically am looking to populate a listbox with the results and allow the user the option to sort by rating, estimated cost, or distance (obviously changing the sort order of the underlying record source). I cannot set the RowSource propety directly, as the resulting string will often times be longer than what is allowed.
I am tempted to blow up my vendor object, and just create separate functions that I could include in a query, even though it would increase the amount of processing time necessary to pull the information. I would really appreciate the recommendations of anyone who has experience with an object oriented approach.
I have created a Vendor object, which when initialized will pull pertinent stats concerning my various vendors. I have added several properties that will return the results of more complex calculations if their values are not already set.
I can now create and destroy a Vendor object, obtaining the pertinent information I need, in about 235 miliseconds.
Code:
Sub TestOne()
Dim Vendor As Vendor
Dim stpWtch As StopWatch
Set stpWtch = New StopWatch
Set Vendor = New Vendor
stpWtch.StartTimer
Vendor.InitializeFirm (2)
MsgBox "Name: " & Vendor.Name & vbCrLf _
& "ID: " & Vendor.ID & vbCrLf _
& "Rating: " & Vendor.CurrentRating & vbCrLf _
& "Distance: " & Vendor.Distance("63042") & vbCrLf _
& "Cost: " & Format(Vendor.EstimatedCost("63042"), "currency") & vbCrLf _
& "Time: " & stpWtch.Formatted
Set Vendor = Nothing
Set stpWtch = Nothing
End Sub
This is where I get lost using the object oriented approach. I now need to create vendor objects for each vendor in a pre-defined subset, sort the information, and display it back to the user.
First, I am a little shaky on creating and working with a collection of objects, but I think I can work through that.
My real problem is that with the exception of creating a temp table to store the retrieved information (which doesn't seem preferable in a multiuser environment), I cannot think of a good way to display the data back to the user. I basically am looking to populate a listbox with the results and allow the user the option to sort by rating, estimated cost, or distance (obviously changing the sort order of the underlying record source). I cannot set the RowSource propety directly, as the resulting string will often times be longer than what is allowed.
I am tempted to blow up my vendor object, and just create separate functions that I could include in a query, even though it would increase the amount of processing time necessary to pull the information. I would really appreciate the recommendations of anyone who has experience with an object oriented approach.