Solved

Polymorphism In Access

Posted on 2004-10-19
12
315 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:numeriss
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 10

Accepted Solution

by:
ALaRiva earned 300 total points
ID: 12351068
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
 

Author Comment

by:numeriss
ID: 12351088
this is the function i use in every form

Public Function MyFunction() As String
  MyFunction = "Administration"
End Function
0
 
LVL 10

Assisted Solution

by:ALaRiva
ALaRiva earned 300 total points
ID: 12351201
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 50

Assisted Solution

by:Steve Bink
Steve Bink earned 200 total points
ID: 12351206
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
 

Author Comment

by:numeriss
ID: 12351446
I damnit I was mistyping the MyFunction and since intellisence don't show up on polymorphism I didn't noticied
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 12351475
Well, that'll do it to ya!!! LOL, Glad you got it sorted out.
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 12351486
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
 
LVL 10

Expert Comment

by:ALaRiva
ID: 12351503
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
 
LVL 50

Expert Comment

by:Steve Bink
ID: 12351582
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
 
LVL 10

Expert Comment

by:ALaRiva
ID: 12351650
@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
 
LVL 50

Expert Comment

by:Steve Bink
ID: 12351814
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
 
LVL 1

Expert Comment

by:powlin
ID: 12352259
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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question