Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Class module to save and manage BOOKMARKS for formsHelpful Member! 

cloverdog (TechnicalUser) (OP)
30 Mar 10 9:30
Hello.  I am new to classes and have not used bookmarks much but I have use for saving a bookmark and a string to a 2D array, used as a ring buffer.  I have the code working in some forms but use it so much it would easier if I could develop it into a class.

The problem I face is that in the class version I want to pass a bookmark  and a string  to the class as elements of a 2D array.  A form can then store and later retrieve these details from the class as required.  

Works great in the form version, which does not use a class to manage the ring buffer, but I cannot get the bookmark and string to be accepted by the class version when passing them over from the form.

The property Let is as follows:

Public Property Let SaveToRingBuffer(inBookmark As BOOKMARK, inStrCustName As String)
    SaveBookmarkToRingBuffer inBookmark, inStrCustName
End Property

I am trying to pass these to the class with the following line of code in the form addressing the class:

    clsRingBuff.SaveToRingBuffer Me.BOOKMARK, "FredSmith"

I face 2 problems first the intellisense only shows the first parameter (ie BOOKMARK).

Secondly if I rmove the second string to get the bookmark working I get an "invalid use of property" error.

I am instantiating the class in the FormOpen subroutine with
Set clsRingBuff = New clsRingBuffer

The declaration of the class is at the top of the form as:
Private clsRingBuff As clsRingBuffer

Any help would be greatly appreciated.

Many thanks
Helpful Member!  Golom (Programmer)
30 Mar 10 9:42
You are getting "invalid use of property" because the correct form of a property is


Public Property Let myProperty(PropertyValue As ...)

Only one argument (the value) is allowed so you cannot have more than one argument in a Property Let. If you change it to a Sub (i.e. a Method in Class terminology) then it should work.


Public Sub SaveToRingBuffer(inBookmark As BOOKMARK, inStrCustName As String)
MajP (TechnicalUser)
30 Mar 10 9:58
"I face 2 problems first the intellisense only shows the first parameter (ie BOOKMARK)"

I have never seen this before and your instantiation sounds correct.  There is likely something else going on.  My first guess is that you have a duplicate name, procdure, or module somewhere.  
1) Ensure you have "Option Explicit" on all modules
2) I would Compile and see if there is any identified problems.
3) Then I would use the find. And check

Make sure you did not mistakenly give two procedures the same name, procedure and object the same name, double procedure, etc.
MajP (TechnicalUser)
30 Mar 10 10:02
  Good catch I do not know what I was thinking.

  Can you explain the purpose of what you are doing? Saving bookmarks can be very problematic since every instantiation of a recordset creates a unique set of bookmarks and these are unique every time you requery the data. You are much better off saving the primary key.
cloverdog (TechnicalUser) (OP)
30 Mar 10 10:04
Thank you for your quick reply.  I understand the single argument and wonder if a custom data type will get round that.

More pressing is that I cannot see where I have breached the correct form of the property?

MAny thanks
Golom (Programmer)
30 Mar 10 10:17


I cannot see where I have breached the correct form of the property



Public Property Let SaveToRingBuffer( _
inBookmark As BOOKMARK, _       <-- First Argument
inStrCustName As String)        <-- Second Argument ILLEGAL!
MajP (TechnicalUser)
30 Mar 10 10:21
"I understand the single argument and wonder if a custom data type will get round that."

No do what Golom said. Class modules can have properties, procedures, and functions.
This looks like a procedure.  If you need to return a value then make it a function.
cloverdog (TechnicalUser) (OP)
30 Mar 10 10:26

Thank you for that.  It may well be that I have used a similar name as I have hacked the changes into a form which ran its own version of the code and commented that out to try and cludge it together to debug the code class.

The purpose of the class is that I have a form for client records,for example, and when working it is easy to get lost as calls come in from different clients.  The aim of the class is to allow the user to step back between the most recent clients using 2 navigation buttons for forwards and backwards between the most recent clients.  

I use a ring buffer which when full overwrites the oldest.  Using the back or forwards button the user can then navigate through the most recent clients. Clients are initially selected using a standard combo box as a record selector.

I have other forms where a working ring buffer would be useful but it would be neater to re-utilise the code.  Hence a class seems ideal.

Thank you  
Golom (Programmer)
30 Mar 10 10:40
I'm with MajP on this.

Presumably you are retrieving the clients into a recordset and, I would assume, the ClientIDs are unique. Retaining bookmarks has all the disadvantages that MajP described. If you instead retain unique keys then you can use the FindFirst / FindLast / FindNext / Seek methods of the recordset in DAO or the Find / Seek methods in ADO.

In addition to avoiding the problems of bookmarks, that approach gives you a way of displaying what the last or next clientIDs are. With the bookmark approach you must reposition the recordset to get that information.
cloverdog (TechnicalUser) (OP)
30 Mar 10 10:50

Thank you I see you mean: don't put the second arg in.  I was running the code without the second arg but there is a typo in my original post where I was saying that ("Secondly if I rmove the second string") so it wasn't clear.  Appologies for that.

A thing that I am a bit worried about is that the db regularly opens up various instantiations of the basic client form, ie: all clients; current clients only; cancelled clients only.  I thought by having the properties and methods Private then there would be less chance of problems caused by multiple forms which each open a copy of the class.  As I say they are new to me.

Thank you for your time.
Golom (Programmer)
30 Mar 10 11:40
We may be suffering a terminology problem here.

The definition of class properties and methods happens inside the class. If you want those properties and/or methods visible outside the class then they must be declared Public.

In contrast, an instance of a class is created outside the class (i.e. in a form, module, another class, etc.). For example


Private myInstance As Class1
If that statement appeared in the General Declarations section of a form then myInstance would be visible only to routines in that form.

Thus each instance of a form can have its own instance(s) of a class without the risk of different forms getting confused about which instance they are using.

As MajP and I said before, you can use a method (i.e. Sub) in place of the property and the code inside the Sub would be the same as if it had been a property except that you can now have two arguments.

You can still have Property Get calls for each of those arguments even though there is no Property Let corresponding to them.
cloverdog (TechnicalUser) (OP)
3 Apr 10 8:41
Golom and Majp

Thank you for your help and advice.  I have re-written the class to use a public function to handle the ringbuffer and return the next record to set the form to.  I have also replaced the use of bookmarks with using the uniqueID of each forms underlying recordset and it works really well.

Once again thanks for the help and the tutorial which was really helpful:)


Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close