confused about classes and displaying forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to learn object oriented programming using Access. I'm creating a
class to handle a calendar. The problem I've run into is that as soon as my
class needs to display a form, control exits my class module and I can no
longer access my class properties. Is object-oriented programming in Access
really possible?

David
 
Well, first, each form is in fact a object, and you can have multiple copies
of that object (same form..open more then once).

So, in fact act, when you create a form, you are creating a class object.

So, as a introduction to creating objects...just build a form..and you
accomplished this feat.

There is NO reason I can see to open, or try and use a class object module
in ms-access to simply open, or display a form
(and, if you do..it should be a COPY of the form..not the forms base
object - since then you would be able to have multiple copies of the
object...and presumably then multiple copies of the form open).

however, it is FAR easier to simply put your code into the forms
module...and have multiple copies of the form open if you need.

If you don't need multiple copies of the form open..then why are you using a
class module to open the form in the first place (it is a waste of time and
effort on your part......and gains your nothing). And, do you need multiple
copies of the object in memory? (again, if you don't..then likely you don't
need your approach at all).

Unless you explain what you are trying to accomplish here, I can't see the
need for you to create class object given what you have so far.

However, if you are looking for some ideas as to WHEN, or WHY you would use
a class object in ms-access, you can read my article here:

http://www.members.shaw.ca/AlbertKallal/Articles/WhyClass.html
 
Thanks for the information. That was a very useful article.
At the moment I am just going through some self-exercises to learn how
classes work. I've written a class to process a stack and to process
temporary tables.
I already have a completely written calendar but I was hoping to simplify
the interface to enable users to say things like
Calendar.Create
Calendar.Caption = "Set Expiration Date"
Calendar.DefaultDate = "1/1/2006"
Calendar.Display
MyDate = Calendar.Date

-David
 
Calendar.Create
Calendar.Caption = "Set Expiration Date"
Calendar.DefaultDate = "1/1/2006"
Calendar.Display
MyDate = Calendar.Date

Ok...you are off to a good start here!!

The minor problem with the above is that of course the above code would not
"wait" for the calendar prompt. So you have:
Calendar.Display
MyDate = Calendar.Date

The problem with the above is of course the "mydate" assigned would not be
much help, since there is no way for the code to "wait" for user input to
then "continue" execution and set MyDate.

However,...you *could* use the technique outlined in my article here:

http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html

So, your "display" code method (a public function) in the class object
could:

docmd.OpenForm "frmMyCollCalendar",,,,,acDialog, m_date

'...the code that follows would use the isloaded() as outlined in my aritcle
to stuff the date into "date"

So, the above could be written to "wait"...but then again...so can a simple
call to a sub.

Hence, likey it would just be better to use my above article to create a
routine like

Call getMyDate("Enter Date For birthday",me.BirthDay)

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top