Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call function 2

Status
Not open for further replies.

jon92

Technical User
May 30, 2001
37
GB
How do I call a function in an update query?
I am trying to capitalise names in a name field

I have found a function that will do this named:
Function proper(var As Variant) As Variant

what do I enter in the QBE grid
update to ?
criteria ?

Help needed please
 
Paste in SQL like this:


update [mytable] set [mytable].[myfield] = proper([mytable].[myfield])


Your function should be in a module.

Sometimes its better to test a function via SQL before doing an update. Test doing something like this:


select [mytable].[myfield], proper([mytable].[myfield]) as name_proper from [mytable]



This way you can manually validate what changes would look like before actuall changing data.



Mike Pastore

Hats off to (Roy) Harper
 
Thanks for replying Mike

I have tried what you suggest and I receive the following error:
Ambiguous name in query expression proper([mytable].[myfield])'.

Jon
 
John,

Can you send me the SQL from your query?

Mike Pastore

Hats off to (Roy) Harper
 
SQL:

update [tblbarvisit] set [tblbarvisit].[barid] = proper([tblbarvisit].[barid])
 
I replicated your logic in a db as:

UPDATE tblBarVisit SET tblBarVisit.barID = proper(tblBarVisit.barID);

Are you sure your function is available? To check this:

CTL+G, this brings up code window.

Type in:

?proper("mike pastore")

You should see "Mike Pastore" (assuming your function is working.


Mike Pastore

Hats off to (Roy) Harper
 
It looks like my function isn't working

I received: Ambiguous name detected: proper
 
You most likely have the function defined twice in your modules. Do a search for "function proper" in your whole project. Get rid of the duplicate function and try again.

Mike Pastore

Hats off to (Roy) Harper
 
Thanks Mike

You were spot on - query now working as I need.

Have a star !

Regards Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top