Connecting Tech Pros Worldwide Forums | Help | Site Map

EVAL

António Castro Caldas
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi All,

I've been trying to get a simple code to run but it hasn't been easy...
I'm designing a Form in Access 2003 and where a givemn 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


Ken Ismert
Guest
 
Posts: n/a
#2: Nov 13 '05

re: EVAL


António,

Try this code in the Form's module:

Function LastUpdate(nField, TempVar)
Dim rCtl As Access.Control

Set rCtl = Me.Controls(nField)
rCtl.Value = TempVar
Me.[ProjectCode].SetFocus

End Function

-Ken

jv
Guest
 
Posts: n/a
#3: Nov 13 '05

re: EVAL


Try this instead of eval(). Forms("PipeLine")(nField) = TempVar

Closed Thread