dbTalk Databases Forums  

dynamic fieldname

comp.databases.filemaker comp.databases.filemaker


Discuss dynamic fieldname in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Twan Kennis
 
Posts: n/a

Default dynamic fieldname - 02-15-2007 , 05:42 AM






This is the situation: 3 fields (type= text)

[field1] (type=date)
[field2] (type=date)
[field_to_set] (type=text)

In this example [field_to_set] contains the value "field1", which is
done using a script:
GotoField([field1])
SetField([field_to_set]; Status(CurrentFieldName))

After a few user-actions, I'd like to update the field contained by
[field_to_set] with a new date.
Problem is: How do I convert the value of [field_to_set] back to a
fieldname, to execute the command SetField([field1], Today())

Thanx for your help.

Twan




Reply With Quote
  #2  
Old   
NScheffey
 
Posts: n/a

Default Re: dynamic fieldname - 02-15-2007 , 08:39 AM






On Feb 15, 6:42 am, "Twan Kennis" <compu... (AT) skb (DOT) nl> wrote:
Quote:
This is the situation: 3 fields (type= text)

[field1] (type=date)
[field2] (type=date)
[field_to_set] (type=text)

In this example [field_to_set] contains the value "field1", which is
done using a script:
GotoField([field1])
SetField([field_to_set]; Status(CurrentFieldName))

After a few user-actions, I'd like to update the field contained by
[field_to_set] with a new date.
Problem is: How do I convert the value of [field_to_set] back to a
fieldname, to execute the command SetField([field1], Today())

Thanx for your help.

Twan
I think what you are looking for is the Evaluate() function, which can
convert text into expressions containing field names. Check the help
file for more details.
Nate



Reply With Quote
  #3  
Old   
Grip
 
Posts: n/a

Default Re: dynamic fieldname - 02-15-2007 , 12:11 PM



On Feb 15, 4:42 am, "Twan Kennis" <compu... (AT) skb (DOT) nl> wrote:
Quote:
This is the situation: 3 fields (type= text)

[field1] (type=date)
[field2] (type=date)
[field_to_set] (type=text)

In this example [field_to_set] contains the value "field1", which is
done using a script:
GotoField([field1])
SetField([field_to_set]; Status(CurrentFieldName))

After a few user-actions, I'd like to update the field contained by
[field_to_set] with a new date.
Problem is: How do I convert the value of [field_to_set] back to a
fieldname, to execute the command SetField([field1], Today())

Thanx for your help.

Twan
You can't. Not directly. You don't mention what version of Filemaker
you're using, but Set Field must be hard coded. There are some ways
around this but you need to specify what version of FM (the easiest
way only works in 8.5) and what you're trying to actually accomplish
(there may be ways of doing it via calculation).

G



Reply With Quote
  #4  
Old   
Helpful Harry
 
Posts: n/a

Default Re: dynamic fieldname - 02-15-2007 , 01:52 PM



In article <1171563103.461925.67640 (AT) p10g2000cwp (DOT) googlegroups.com>,
"Grip" <grip (AT) cybermesa (DOT) com> wrote:

Quote:
On Feb 15, 4:42 am, "Twan Kennis" <compu... (AT) skb (DOT) nl> wrote:
This is the situation: 3 fields (type= text)

[field1] (type=date)
[field2] (type=date)
[field_to_set] (type=text)

In this example [field_to_set] contains the value "field1", which is
done using a script:
GotoField([field1])
SetField([field_to_set]; Status(CurrentFieldName))

After a few user-actions, I'd like to update the field contained by
[field_to_set] with a new date.
Problem is: How do I convert the value of [field_to_set] back to a
fieldname, to execute the command SetField([field1], Today())

You can't. Not directly. You don't mention what version of Filemaker
you're using, but Set Field must be hard coded. There are some ways
around this but you need to specify what version of FM (the easiest
way only works in 8.5) and what you're trying to actually accomplish
(there may be ways of doing it via calculation).
Twan is using the Status function, so that would mean a version of
FileMaker before version 7. )




Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #5  
Old   
Helpful Harry
 
Posts: n/a

Default Re: dynamic fieldname - 02-15-2007 , 01:55 PM



In article <12t8hpblij2dm05 (AT) corp (DOT) supernews.com>, "Twan Kennis"
<computer (AT) skb (DOT) nl> wrote:

Quote:
This is the situation: 3 fields (type= text)

[field1] (type=date)
[field2] (type=date)
[field_to_set] (type=text)

In this example [field_to_set] contains the value "field1", which is
done using a script:
GotoField([field1])
SetField([field_to_set]; Status(CurrentFieldName))
Since the script is using the Go To Field command, why bother with the
Status(CurrentFieldName) function???

You may as well simply hardcode it.
ie.
Go To Field [field1]
Set Field [field_to_set, "field1"]

It probably makes no real difference to anything though.




Quote:
After a few user-actions, I'd like to update the field contained by
[field_to_set] with a new date.
Problem is: How do I convert the value of [field_to_set] back to a
fieldname, to execute the command SetField([field1], Today())
Basically, since there's no Case script command, you have to use a long
string of If statements and hardcode the fieldnames ... although,
because you only have two fields (in the example anyway), it's not a
huge task.
eg.
If [field_to_set = "field1"]
Set Field [field1, Get(CurrentDate)]
End If
If [field_to_set = "field2"]
Set Field [field2, Get(CurrentDate)]
End If



By the way, do not use the Today function. Instead use
Status(CurrentDate).

The Today function is really just a internal Global field within
FileMaker which is set to the "current" date when FileMaker is opened,
and then not changed until you quit and reopen FileMaker. This means
that if your database is open past midnight it will return yesterday's
date.

The Status(CurrentDate) function is calculated every time you use it
and therefore alwasy returns the propr current date.











Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #6  
Old   
Twan Kennis
 
Posts: n/a

Default Re: dynamic fieldname - 02-20-2007 , 03:54 AM



Thanx for your help.
Currently we're using FileMaker 6.0, but soon we will migrate to version
8.5.

It's a pitty dynamic field names for the SetField-function are not
easyly supported, maybe next time.
For now, I implemented the work-around using the If-statement (not very
sexy, but it works...)

If (field_to_set = "field1") then SetField(field1; Status(CurrentDate));
If (field_to_set = "field2") then SetField(field2; Status(CurrentDate));
If ...

Twan



"Helpful Harry" <helpful_harry (AT) nom (DOT) de.plume.com> wrote

Quote:
In article <1171563103.461925.67640 (AT) p10g2000cwp (DOT) googlegroups.com>,
"Grip" <grip (AT) cybermesa (DOT) com> wrote:

On Feb 15, 4:42 am, "Twan Kennis" <compu... (AT) skb (DOT) nl> wrote:
This is the situation: 3 fields (type= text)

[field1] (type=date)
[field2] (type=date)
[field_to_set] (type=text)

In this example [field_to_set] contains the value "field1", which
is
done using a script:
GotoField([field1])
SetField([field_to_set]; Status(CurrentFieldName))

After a few user-actions, I'd like to update the field contained
by
[field_to_set] with a new date.
Problem is: How do I convert the value of [field_to_set] back to a
fieldname, to execute the command SetField([field1], Today())

You can't. Not directly. You don't mention what version of
Filemaker
you're using, but Set Field must be hard coded. There are some ways
around this but you need to specify what version of FM (the easiest
way only works in 8.5) and what you're trying to actually accomplish
(there may be ways of doing it via calculation).

Twan is using the Status function, so that would mean a version of
FileMaker before version 7. )




Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships
;o)




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.