Module Question

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

Guest

I found this code in an Access 2007 programming book and tried to make it
work(using Access 2003)which may be the problem. Does anyone see a problem
with the code which would give me the error message:
"Undefined function 'pcase' in expression.

Public Function Pcase(Anytext as string) as String
'Create a string variable, then store AnyText in that variable already
'Converted to proper case using the built-in StrConv() function
Dim FixedText As String
FixedText = StrConv(Anytext, vbUpperCase)
'Now return the modified string.
Pcase = FixedText

End Function
 
In
Ldappa said:
I found this code in an Access 2007 programming book and tried to
make it work(using Access 2003)which may be the problem. Does anyone
see a problem with the code which would give me the error message:
"Undefined function 'pcase' in expression.

Public Function Pcase(Anytext as string) as String
'Create a string variable, then store AnyText in that variable
already 'Converted to proper case using the built-in StrConv()
function
Dim FixedText As String
FixedText = StrConv(Anytext, vbUpperCase)
'Now return the modified string.
Pcase = FixedText

End Function

I see nothing wrong with the code. Where did you put it and where did
you call it?
 
The book say's to put it in a query example:
use customers table
lname
=PCase([lname])
but when I do I get that error message "Undefined function 'pcase' in
expression"
Now I saved the code in a module with the name PCase just like the book said.

I tryed using just UCase in the query UCase([lname]) and that worked fine
but I can see nothing wrong with the code eventhough I am a newbie.
 
In
Ldappa said:
The book say's to put it in a query example:
use customers table
lname
=PCase([lname])
but when I do I get that error message "Undefined function 'pcase' in
expression"
Now I saved the code in a module with the name PCase just like the
book said.

Did the book tell you to save the *module* with the name "PCase"? The
module should *not* have the same name as the function! Call the module
"modUtilities" (assuming you're going to put more than one useful
procedure in this module), or "modPCase" (if you're only going to put
the one function in it), or *something* else besides the name of any
procedure it contains.
 
Yes the book actually did say to name it PCase as it was also the name of the
downloadable module but I renamed it and it worked perfectly.

Thanks so much for your help!
--
Ldappa


Dirk Goldgar said:
In
Ldappa said:
The book say's to put it in a query example:
use customers table
lname
=PCase([lname])
but when I do I get that error message "Undefined function 'pcase' in
expression"
Now I saved the code in a module with the name PCase just like the
book said.

Did the book tell you to save the *module* with the name "PCase"? The
module should *not* have the same name as the function! Call the module
"modUtilities" (assuming you're going to put more than one useful
procedure in this module), or "modPCase" (if you're only going to put
the one function in it), or *something* else besides the name of any
procedure it contains.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
In
Ldappa said:
Yes the book actually did say to name it PCase

Sounds like you can't trust everything that book says. What book is it?
but I renamed it and it worked perfectly.

Thanks so much for your help!

Very good. You're welcome.
 
Back
Top