A97, NT4.
I've seen an example of this posted here but I can't for the life of me
find it. If I have a lot of controls on a form which all require the same
After Update action, what syntax do you need to pass "Me" to the public
function in a module?
I've tried calling
Public Function libComboFilter(frmForm As Form_Form1) As String
libComboFilter = frmForm.Name
Debug.Print libComboFilter
End Function
from a form called "Form1" with
libComboFilter (Me)
but I get a type mismatch error. I've nothing specific to achieve, I'm just
trying to get the principle right.
Thanks.
Keith. 15 12221
Keith,
are you fishing for Me.ActiveControl? I would think you'd have to
assign that to a variable in your form's code module and then pass the
variable to your function... Something like
Dim strCtrlName as string
Dim strFormName as string
strFormName=me.name
strCtrlName = me.activecontrol.name
X=fSomePublicFunction(strFormName,strCtrlName)
then it's totally unambiguous. pi********@hotmail.com wrote: Keith, are you fishing for Me.ActiveControl? I would think you'd have to assign that to a variable in your form's code module and then pass the variable to your function... Something like
Dim strCtrlName as string Dim strFormName as string strFormName=me.name strCtrlName = me.activecontrol.name
X=fSomePublicFunction(strFormName,strCtrlName)
then it's totally unambiguous.
Well I could make it work like that but I could have sworn I saw some code
on here where the Me keyword was passed on it's own ... maybe I was
mistaken.
Many thanks for a speedy response.
Keith.
Try this:
Public Function MyFunction(frmObject)
MyFunction = frmObject.Name
End Function
Call it this way:
MyName = MyFunction(Me)
--
Ken Snell
<MS ACCESS MVP>
"Keith" <ke*********@AwayWithYerCrap.com> wrote in message
news:Xn************************@10.15.188.42... A97, NT4.
I've seen an example of this posted here but I can't for the life of me find it. If I have a lot of controls on a form which all require the same After Update action, what syntax do you need to pass "Me" to the public function in a module?
I've tried calling
Public Function libComboFilter(frmForm As Form_Form1) As String
libComboFilter = frmForm.Name Debug.Print libComboFilter
End Function
from a form called "Form1" with
libComboFilter (Me)
but I get a type mismatch error. I've nothing specific to achieve, I'm just trying to get the principle right.
Thanks. Keith.
Either
call libComboFilter(Me)
Or
libComboFilter Me
should work, although why you would use a public function for this when the
parameter type you are passing is Form_Form1 I don't know.
I would expect you to either have
Public Function libComboFilter(frmForm As Form) As String
or put the function in the form class module in which case you don't need to
pass a parameter.
--
Terry Kreft
MVP Microsoft Access
"Keith" <ke*********@AwayWithYerCrap.com> wrote in message
news:Xn************************@10.15.188.42... A97, NT4.
I've seen an example of this posted here but I can't for the life of me find it. If I have a lot of controls on a form which all require the same After Update action, what syntax do you need to pass "Me" to the public function in a module?
I've tried calling
Public Function libComboFilter(frmForm As Form_Form1) As String
libComboFilter = frmForm.Name Debug.Print libComboFilter
End Function
from a form called "Form1" with
libComboFilter (Me)
but I get a type mismatch error. I've nothing specific to achieve, I'm
just trying to get the principle right.
Thanks. Keith.
I've been using this approach for years:
How to call a function and pass your form
Me.HelpLabel.Caption = "How is it going"
SomeFunction(Me)
-------------------------------------
Public sub SomeFunction(Calling as form)
Calling.HelpLabel.Caption = "Going really good"
Exit Sub
Hank Reed
Keith wrote: A97, NT4.
I've seen an example of this posted here but I can't for the life of me find it. If I have a lot of controls on a form which all require the same After Update action, what syntax do you need to pass "Me" to the public function in a module?
I've tried calling
Public Function libComboFilter(frmForm As Form_Form1) As String
libComboFilter = frmForm.Name Debug.Print libComboFilter
End Function
from a form called "Form1" with
libComboFilter (Me)
but I get a type mismatch error. I've nothing specific to achieve, I'm just trying to get the principle right.
Thanks. Keith.
Should be:
Public Function libComboFilter(frmForm As Access.Form) As String
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
"Ken Snell" <kt***********@ncoomcastt.renaetl> wrote: Public Function MyFunction(frmObject) MyFunction = frmObject.Name End Function
Call it this way: MyName = MyFunction(Me)
That's it, many thanks indeed Ken. Thanks also to all other respondees.
Keith. www.keithwilby.com
This is bad practice, if you know the type of the argument your procedure
expects then you should declare the argument as that type, not as a variant
which is what this declaration is doing.
--
Terry Kreft
MVP Microsoft Access
"Grumpy Old Man" <ke*********@AwayWithYerCrap.com> wrote in message
news:Xn************************@10.15.188.42... "Ken Snell" <kt***********@ncoomcastt.renaetl> wrote:
Public Function MyFunction(frmObject) MyFunction = frmObject.Name End Function
Call it this way: MyName = MyFunction(Me)
That's it, many thanks indeed Ken. Thanks also to all other respondees.
Keith. www.keithwilby.com
"Terry Kreft" <te*********@mps.co.uk> wrote: This is bad practice, if you know the type of the argument your procedure expects then you should declare the argument as that type, not as a variant which is what this declaration is doing.
You're referring to the omission of "As Form"? I've included that and it
works fine. Thanks for your response Terry, much appreciated.
Regards,
Keith.
Terry - I concur wholeheartedly with defining argument types. I left it out
of the example as I wasn't sure if the called function would be used just
for a form, or also might be used for a report.
--
Ken Snell
<MS ACCESS MVP>
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:tq********************@karoo.co.uk... This is bad practice, if you know the type of the argument your procedure expects then you should declare the argument as that type, not as a variant which is what this declaration is doing.
-- Terry Kreft MVP Microsoft Access
"Grumpy Old Man" <ke*********@AwayWithYerCrap.com> wrote in message news:Xn************************@10.15.188.42... "Ken Snell" <kt***********@ncoomcastt.renaetl> wrote:
> Public Function MyFunction(frmObject) > MyFunction = frmObject.Name > End Function > > > Call it this way: > MyName = MyFunction(Me)
That's it, many thanks indeed Ken. Thanks also to all other respondees.
Keith. www.keithwilby.com
Ken,
Good point, but then I would at least go for As Object.
--
Terry Kreft
MVP Microsoft Access
"Ken Snell" <kt***********@ncoomcastt.renaetl> wrote in message
news:l8********************@comcast.com... Terry - I concur wholeheartedly with defining argument types. I left it
out of the example as I wasn't sure if the called function would be used just for a form, or also might be used for a report.
--
Ken Snell <MS ACCESS MVP>
"Terry Kreft" <te*********@mps.co.uk> wrote in message news:tq********************@karoo.co.uk... This is bad practice, if you know the type of the argument your
procedure expects then you should declare the argument as that type, not as a variant which is what this declaration is doing.
-- Terry Kreft MVP Microsoft Access
"Grumpy Old Man" <ke*********@AwayWithYerCrap.com> wrote in message news:Xn************************@10.15.188.42... "Ken Snell" <kt***********@ncoomcastt.renaetl> wrote:
> Public Function MyFunction(frmObject) > MyFunction = frmObject.Name > End Function > > > Call it this way: > MyName = MyFunction(Me)
That's it, many thanks indeed Ken. Thanks also to all other respondees.
Keith. www.keithwilby.com
"Terry Kreft" <te*********@mps.co.uk> wrote: Good point, but then I would at least go for As Object.
Terry,
I've used "As Form" and everything works fine. Would "As Object" be a
better option?
Regards,
Keith.
Not if it is just Forms you are passing, Ken was making the point that by
declaring the argument as a variant (which is the implicit data type if no
explicit declaration is made) he was leaving open the option to pass a
Report as well.
My point was that in that case declaring the argument as Object would be a
tighter declaration than as Variant.
If your procedure now works stick with it.
--
Terry Kreft
MVP Microsoft Access
"Grumpy Old Man" <ke*********@AwayWithYerCrap.com> wrote in message
news:Xn************************@10.15.188.42... "Terry Kreft" <te*********@mps.co.uk> wrote:
Good point, but then I would at least go for As Object.
Terry,
I've used "As Form" and everything works fine. Would "As Object" be a better option?
Regards, Keith.
"Terry Kreft" <te*********@mps.co.uk> wrote: Not if it is just Forms you are passing, Ken was making the point that by declaring the argument as a variant (which is the implicit data type if no explicit declaration is made) he was leaving open the option to pass a Report as well.
My point was that in that case declaring the argument as Object would be a tighter declaration than as Variant.
If your procedure now works stick with it.
Thanks for the clarification.
Yes, I concur.
--
Ken Snell
<MS ACCESS MVP>
"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:DK********************@karoo.co.uk... Ken, Good point, but then I would at least go for As Object.
-- Terry Kreft MVP Microsoft Access
"Ken Snell" <kt***********@ncoomcastt.renaetl> wrote in message news:l8********************@comcast.com... Terry - I concur wholeheartedly with defining argument types. I left it out of the example as I wasn't sure if the called function would be used just for a form, or also might be used for a report.
--
Ken Snell <MS ACCESS MVP>
"Terry Kreft" <te*********@mps.co.uk> wrote in message news:tq********************@karoo.co.uk... > This is bad practice, if you know the type of the argument your procedure > expects then you should declare the argument as that type, not as a > variant > which is what this declaration is doing. > > -- > Terry Kreft > MVP Microsoft Access > > > "Grumpy Old Man" <ke*********@AwayWithYerCrap.com> wrote in message > news:Xn************************@10.15.188.42... >> "Ken Snell" <kt***********@ncoomcastt.renaetl> wrote: >> >> > Public Function MyFunction(frmObject) >> > MyFunction = frmObject.Name >> > End Function >> > >> > >> > Call it this way: >> > MyName = MyFunction(Me) >> >> That's it, many thanks indeed Ken. Thanks also to all other >> respondees. >> >> Keith. >> www.keithwilby.com > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Abe Frohnman |
last post by:
Hello all,
I'm passing a reference to a class into the constructor of a form, like
so: public MyForm(int count, ref Area myArea) {...}
How can I use myArea outside the constructor? Should I...
|
by: aaa |
last post by:
I am having trouble getting a complex data type to get passed to a non-COM
dll's function by ref and return back data from that object. Simple data
types work fine but when I try the complex data...
|
by: Maxim |
last post by:
Hi!
A have a string variable (which is a reference type).
Now I define my Method like that:
void MakeFullName(string sNamePrivate)
{
sNamePrivate+="Gates"
}
|
by: blue |
last post by:
We often get connection pooling errors saying that there are no available
connections in the pool.
I think the problem is that we are passing around open readers all over the
place. I am...
|
by: DareDevil |
last post by:
I have written a method that should modify the folder path passed to it into one that exists and is selected by the user. It then returns a boolean depending on whether a folder path was selected by...
|
by: Andrew Bullock |
last post by:
Hi,
I have two classes, A and B,
B takes an A as an argument in its constructor:
A a1 = new A();
B b = new B(a1);
|
by: TS |
last post by:
I was under the assumption that if you pass an object as a param to a method
and inside that method this object is changed, the object will stay changed
when returned from the method because the...
|
by: Deckarep |
last post by:
Hello fellow C# programmers,
This question is more about general practice and convention so here
goes:
I got into a discussion with a co-worker who insisted that as a general
practice all...
|
by: Andy Baker |
last post by:
I am attempting to write a .NET wrapper in C# for an SDK that has been
supplied as a .LIB file and a .h header file. I have got most of the
functions to work but am really struggling with the...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| |