473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Eval problem

stephane
str_comand = "Forms![dossier]![" & с_select & "].Value = 123"

Eval(str_comand) ' it doesn't works

You are trying to assign a value within the string. You can't do this.
Feb 8 '07 #1
11 3043
>>You are trying to assign a value within the string. You can't do this.

str_comand = "Forms![dossier]![" & с_select & "].Value = ""123"""

doesn't works too
Feb 8 '07 #2
i can make question more simply
how to set value to field using eval function?

str_comand = "Forms![dossier]![testtest].Value = ""text"""
Eval(str_comand)

not works
Feb 8 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Try this

Expand|Select|Wrap|Line Numbers
  1.  
  2. str_comand = "Forms![dossier]![testtest] =" & "text"
  3. Eval(str_comand)
It's possible the Eval() won't work like this but it's worth testing.
Feb 8 '07 #4
Try this

Expand|Select|Wrap|Line Numbers
  1.  
  2. str_comand = "Forms![dossier]![testtest] =" & "text"
  3. Eval(str_comand)
It's possible the Eval() won't work like this but it's worth testing.
it doesn't works too (
well, there is no errors, its simply no changes in 'testtest' field.


is anybody know other methods to change field, which name contents at the variable? mayby there is way without eval() using?
Feb 8 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
it doesn't works too (
well, there is no errors, its simply no changes in 'testtest' field.


is anybody know other methods to change field, which name contents at the variable? mayby there is way without eval() using?
Forgetting about the Eval what are you trying to do?
Feb 8 '07 #6
Rabbit
12,516 Expert Mod 8TB
It seems like you're trying to set the value for a control that could be a different control every time. And for some reason, you don't know what that control is before hand and no event from that control will activate in response. This is one of the few situations where I can see needing the functionality that you want.

Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2.  
  3. For Each ctl In Form.Controls
  4.      If ctl.Properties("Name") = strName Then
  5.           ctl = "123"
  6.           Exit For
  7.      End If
  8. Next ctl
  9.  
Feb 8 '07 #7
Forgetting about the Eval what are you trying to do?
i've got a form. simply, it there is two text fields, 'text1' and 'text2' and button
i've got a global variable field_name
field_name can be equal
field_name = "text1" or field_name = "text2"
it takes from another part of form, and it's so.

clicking on button, a need to set value of the one of those two fields as "test"

when it's equal text1 i need set "test" as text1 value
when it's equal text2 needs to set "test" as text2 value

it is a simplistically example. at real sutiation number of fields is unknown, so i can't use
Expand|Select|Wrap|Line Numbers
  1. if field_name = "text1" then
  2. Forms![dossier]![text1].Value = "test"
  3. elseif field_name = "text2" then
  4. Forms![dossier]![text2].Value = "test"
  5. end if
  6.  
Feb 8 '07 #8
It seems like you're trying to set the value for a control that could be a different control every time. And for some reason, you don't know what that control is before hand and no event from that control will activate in response. This is one of the few situations where I can see needing the functionality that you want.

Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2.  
  3. For Each ctl In Form.Controls
  4.      If ctl.Properties("Name") = strName Then
  5.           ctl = "123"
  6.           Exit For
  7.      End If
  8. Next ctl
  9.  
Thanks, Rabbit,
i'll try it tomorrow
Feb 8 '07 #9
Rabbit
12,516 Expert Mod 8TB
There could be a simpler solution. In addition to wanting to know what you want to do with the code is why you need to do it this way. You've told us what you want to do, can you tell us why?
Feb 8 '07 #10
There could be a simpler solution. In addition to wanting to know what you want to do with the code is why you need to do it this way. You've told us what you want to do, can you tell us why?
at the real situation i've got a form width a lot of "datetime" fields.
to make interface more friendly i use object Calendar Control 11.0.
but i don't what to make a lot of copies of the calendar object. So i make one calendar, hide it, and when user clicks one of the datetimefields, i change the coordinates of the calendar, show it and set varible for current datetime field. When user selects date, calendar hides, and value of the current datetime field sets equal calendar value selected.

so, when the calendar hides, i know name of the current field and sets its value.

sorry for bad english:]
Feb 8 '07 #11
NeoPa
32,556 Expert Mod 16PB
It sounds like you want the Me.Controls(ControlName) syntax.
The name of the control (ControlName) can be stored in a string variable or can be any formula that returns a string.
Let us know if this solves your problem.
Feb 10 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: Stuart | last post by:
why won't the following work for(var i=0;i<pics;i++){ eval('img'+i) = new Image(wth,hgt) eval('img'+i+'.src') = 'http://www.mypics/'+i+'1.gif' } basically I am trying to create a numer of...
7
by: Reply Via Newsgroup | last post by:
This might sound sad... someone requesting a disertation on the 'eval' statement... but... I've been reading someone else's post - they had a huge calander like script and a handful of folk cursed...
6
by: Roebie | last post by:
Hi everyone, I'm having some weird problem with evaluating the continue statement. Within a for loop I'm trying to evaluate a string (generated somewhere earlier) which basically has the continue...
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
8
by: santel_helvis | last post by:
Hi, Here is my code. function CallDisplay() { nodeobj=new mynode(); x="displayId("+nodeobj+")"; eval(x);
3
by: Pauljh | last post by:
Hi All, I'm running some javascript over a server side generated web page and have multiple generated empty select statements, that I want to populate when the page is loaded. As HTML doesn't do...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
5
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns...
12
by: Bill Mill | last post by:
Hello all, I want to have a user able to eval code in a text box. However, if he accidentally types "while(1) { i=0; }" and hits "run", I also want him to be able to hit a stop button such that...
16
by: Fett | last post by:
I am creating a program that requires some data that must be kept up to date. What I plan is to put this data up on a web-site then have the program periodically pull the data off the web-site. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.