"Albert D.Kallal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
>
> The 2nd and more critical issue is that currentdb is a method of the
> JET database engine, and NOT that of ms-access. This means that forms
> expressions, and VB function names can NOT be used when you use
> currentdb.Execute, but YOU CAN use VBA and even forms!myform!myfield
> name expressions when you use the docmd.
I think you're mistaken, Albert, or I'm not understanding you properly.
You *can* use VBA functions in queries executed by the DAO Execute
method, so long as the query is being executed from within Access. For
example, from code inside an Access application, I can write
CurrentDb.Execute _
"UPDATE Table1 SET [TextField] = Mid([textField],6)"
or even
CurrentDb.Execute _
"UPDATE Table1 SET [TextField] = MyCustomFunction([textField])"
But from any other application that just uses the Jet engine, I can't do
it. For example in an application developed with Visual Basic -- not
Access -- I can't run this query:
Set db = DBEngine.OpenDatabase("MyDB.mdb")
'*** Won't work
db.Execute _
"UPDATE Table1 SET [TextField] = MyCustomFunction([textField])"
I don't think this query will work, either:
' *** Will this work?
db.Execute _
"UPDATE Table1 SET [TextField] = Mid([textField],6)"
But I'm not completely sure about that.
What you can't do with the Execute method is use queries that refer to
controls on forms -- *unless* you fill those values in as parameters
before executing. I use a QueryDef object and its Parameters collection
to accomplish this, when I have to.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)