By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,222 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,222 IT Pros & Developers. It's quick & easy.

Using VBA function for Forms

P: n/a
This is the first time that I have tried to use a function as the
default value for a form. The function appears to work when I run it in
VBA, and I have saved it and it shows up in my Module list. However,
when I make a form, with a text box then in the Default put

= FunctionName()

all I get is "#Name?" in the text box.
Can anyone please help?

Thanks

Alan

Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There cannot be a space between the equal sign and the function name.
The function name must be the name of a function, not the name of a
module. If it is in a standard module and not in the form's class
module it must be a Public function NOT a Private function.

Sometimes the control doesn't pick up the function call until after
the form has been saved & then re-opened. Try that.

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQCXhBoechKqOuFEgEQI3bwCg2ZSdUPPUhiH7t4YP0BbHV4 cB/14AmgMZ
ps2WzzFXy1LIHvKYzzDKsAcq
=vM6p
-----END PGP SIGNATURE-----
Alan Brasel wrote:
This is the first time that I have tried to use a function as the
default value for a form. The function appears to work when I run it in
VBA, and I have saved it and it shows up in my Module list. However,
when I make a form, with a text box then in the Default put

= FunctionName()

all I get is "#Name?" in the text box.


Nov 12 '05 #2

P: n/a
Alan Brasel wrote:
This is the first time that I have tried to use a function as the
default value for a form. The function appears to work when I run it in
VBA, and I have saved it and it shows up in my Module list. However,
when I make a form, with a text box then in the Default put

= FunctionName()

all I get is "#Name?" in the text box.


I can duplicate this behavior; it seems to me that you cannot have a
DefaultValue when the ControlSource is Null.

Is your textbox bound?

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #3

P: n/a
The text box is UNbound. I found that what I was doing wrong is that I
named the module the same name as the function - apparently that is not
allowed. After renaming my module, everything works just fine.

Thanks for your help.

Alan

Bas Cost Budde wrote:
Alan Brasel wrote:
This is the first time that I have tried to use a function as the
default value for a form. The function appears to work when I run it
in VBA, and I have saved it and it shows up in my Module list.
However, when I make a form, with a text box then in the Default put

= FunctionName()

all I get is "#Name?" in the text box.

I can duplicate this behavior; it seems to me that you cannot have a
DefaultValue when the ControlSource is Null.

Is your textbox bound?


Nov 12 '05 #4

P: n/a
I found that what I was doing wrong is that I named the module the same
name as the function - apparently that is not allowed. After renaming
my module, everything works just fine.

Thanks for your help.

Alan

MGFoster wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There cannot be a space between the equal sign and the function name.
The function name must be the name of a function, not the name of a
module. If it is in a standard module and not in the form's class
module it must be a Public function NOT a Private function.

Sometimes the control doesn't pick up the function call until after
the form has been saved & then re-opened. Try that.

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQCXhBoechKqOuFEgEQI3bwCg2ZSdUPPUhiH7t4YP0BbHV4 cB/14AmgMZ
ps2WzzFXy1LIHvKYzzDKsAcq
=vM6p
-----END PGP SIGNATURE-----
Alan Brasel wrote:
This is the first time that I have tried to use a function as the
default value for a form. The function appears to work when I run it
in VBA, and I have saved it and it shows up in my Module list.
However, when I make a form, with a text box then in the Default put

= FunctionName()

all I get is "#Name?" in the text box.



Nov 12 '05 #5

P: n/a
Alan Brasel wrote:
The text box is UNbound. I found that what I was doing wrong is that I
named the module the same name as the function - apparently that is not
allowed. After renaming my module, everything works just fine.
Indeed. Nor can you name your project the same as a function or a module.
Thanks for your help.


Any time--but how have I helped? ;-)
--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.