EVAL

  • Thread starter António Castro Caldas
  • Start date
A

António Castro Caldas

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
 
D

Dirk Goldgar

António Castro Caldas said:
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

Answered in the .modulesdaovba newsgroup, where you also posted this
question independently. That's called "multiposting", and it's
generally frowned on because others don't know what answers have already
been given, and so they duplicate the effort. Also it's harder for you
to keep track of the various replies, and it's harder for later readers
of the question, who may be looking for the same answer, to learn what
they need.

In most cases a single, well-chosen newsgroup will do. If your question
really is relevant to more than one newsgroup, the approved technique is
to "crosspost" it instead, by listing multiple newsgroups in the To: or
Newsgroups: line of a single message. If you do that, the message and
any replies will appear in all the listed newsgroups automatically,
which is beneficial to all concerned.
 
J

John Nurick

Hi António,

Try something like this

Sub LastUpdate(nField, TempVar)
'if no return value, no need to use Function

Forms("Pipeline").Controls(nField).Value = TempVar

Me.[ProjectCode].SetFocus

End Sub

If nField is the name of a field in the form's recordset rather than the
name of a control, try

Forms("Pipeline").Recordset.(nField).Value = TempVar


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top