Polymorphism In Access

in want to use polymorphism in VBA

the thing i try is this

dim frm as form
set frm = Forms("a type of a form")
msgbox frm.MyFunction
set frm = Forms("another form")
msgbox frm.MyFunction

MyFunction is declared in the 2 custom form i created but I don't in the standard Form class
I also tried created frm as Variant or a Object but did'nt worked
numerissAsked:
Who is Participating?
 
ALaRivaConnect With a Mentor Commented:
If the Function is to be called from another object outside of that form's scope, then you need to make sure that it's set to Public instead of Private.

i.e.
Public Function MyFunction()

instead of
Private Function MyFunction()

-Anthony
0
 
numerissAuthor Commented:
this is the function i use in every form

Public Function MyFunction() As String
  MyFunction = "Administration"
End Function
0
 
ALaRivaConnect With a Mentor Commented:
What's the purpose of the Function?  What do you use it for?  

If you are using the same thing in every form, then why not use one Public Function in a standard Module instead?

-Anthony

0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Steve BinkConnect With a Mentor Commented:
You also have to be sure the form is loaded (read as: opened) before referencing it.  The Forms collection only holds forms currently loaded by Access.
0
 
numerissAuthor Commented:
I damnit I was mistyping the MyFunction and since intellisence don't show up on polymorphism I didn't noticied
0
 
ALaRivaCommented:
Well, that'll do it to ya!!! LOL, Glad you got it sorted out.
0
 
ALaRivaCommented:
What's with the B Grade?  

Not that Points or Grades matter to me, but I know that we were going through all of the standard protocols for answering a question like this, yet you gave us a B?
0
 
ALaRivaCommented:
Definitely not trying to cause any trouble either, I'm just curious.   Is that a standard grade when you solve the issue yourself?

-Anthony
0
 
Steve BinkCommented:
The 'standard' response would have been to PAQ/Refund or Delete/Refund the question.  But if the questionner wants to award points, I doubt very much any of us will stop them.  :)

numeriss:  If you would like to have your points refunded for this question, post a request in the Community Support TA.  Good luck with the rest of your project!
0
 
ALaRivaCommented:
@routinet,
    Thanks for the clarification.  I wasn't sure, but I know that others get upset with B Grades so I figured I would ask what the reasoning and standard is.

-Anthony
0
 
Steve BinkCommented:
It's all good.  If you are interested in seeing the suggested guidelines for grading questions, take a look at:

http://www.experts-exchange.com/help.jsp#hi73

Remove the "#hi73" to start at the beginning of the FAQ (or scroll up!)
0
 
powlinCommented:
I'm grading depending on who the answer helped me if the answer was right i put excellent, if the answer was good but not the one i looked for but helped me finding the problem i give B and I think that B stand for good, that is a really positive grade, i'm happy when I get B on my school exam hehe
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.