Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

EVAL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Antonio - 29 Jun 2005 16:59 GMT
Hi,

I'm designing a Form in Access 2003 and where a given event takes place, I
call up a Function. Basically, the Function holds 2 arguments. One of them is
the name of the field in the form to change, the other one is the value.

Here's the function:

Function LastUpdate(nField, TempVar)
Dim strCtl As String

   strCtl = "Forms![Pipeline]![" & nField & "]=" & TempVar
   Eval (strCtl)
   Me.[ProjectCode].SetFocus

End Function

Here's how I call it:

Call LastUpdate("GoGet", iGoget)

In the end, the [GoGet] field doesn't store the value that I pass through
the TempVar variable.
In Debug Mode, I can see that the strCtl is ok but somehow the EVAL function
isn't producing the effect that I want.

Anyone?

Thanks
Antonio
Dirk Goldgar - 29 Jun 2005 18:11 GMT
> Hi,
>
[quoted text clipped - 27 lines]
> Thanks
> Antonio

The Eval function can't be used to perform an assignment statement like
that -- it can only be used to evaluate an expression that returns a
value.  But it seems you could just rewrite your code like this:

'----- start of revised code -----
Function LastUpdate(nField, TempVar)

   Forms!Pipeline.Controls(nField) = TempVar
   Me.[ProjectCode].SetFocus

End Function
'----- end of revised code -----

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Antonio - 30 Jun 2005 10:13 GMT
THANKS!

> > Hi,
> >
[quoted text clipped - 40 lines]
> End Function
> '----- end of revised code -----
Larry Linson - 09 Jul 2005 00:05 GMT
> The Eval function can't be used to
> perform an assignment statement like
> that -- it can only be used to evaluate
> an expression that returns a
> value.

But, a very nice feature is that, because Functions, by definition, return a
value, you can execute a Function, which might well do something in addition
to just returning a value.

 Larry Linson
 Microsoft Access MVP
Dirk Goldgar - 09 Jul 2005 05:27 GMT
>  > The Eval function can't be used to
>  > perform an assignment statement like
[quoted text clipped - 5 lines]
> return a value, you can execute a Function, which might well do
> something in addition to just returning a value.

Indeed yes!  The function doesn't even have to return any meaningful
value -- it can return Null, either explicitly or by default.  When
using Eval this way, you do have to be sure to include the parentheses
after the function name, even if the function doesn't require any
arguments.  For example,

   v = Eval("MyFunction()")

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.