Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box and numeric value 1

Status
Not open for further replies.

Nro

Programmer
May 15, 2001
337
CA
Salut.

I'm using Filemkr 6 (or 7).

I want to create an value list, say Status.

Status : 1 = Active, 2 = Inactive and 3 = Suspended

I want to register only the numeric value (1, 2 or 3) in the Status field. Is it possible ?

Thanks in advance

Nro
 
I don't understand the question, but yes it is possible, but to evaluate the status you have to use a case statement...

Or am I missing something here ....

JW
 
Hi.

Let's say I have one field called "Em_Status" (employee status). This field is numeric

Now, I want to create a value list with theses values

Active
Inactive
Cancelled

The user must select the right status, and the data in the
"Em_Status" field must be 1 (Active) or 2 (Inactive) and so on. I don't want to register the word "Active" or the word "Inactive" in the field Em_status

I hope it's more clear

Thanks
Nro

 
You can use the same technique as for the telephone mask.

Make a field statusValue, text, popup list, valuelist with Active, Inactive etc.


Make your Em_Status a calculation with case statement, something like :

Case (
statusValue = “Active” ; “1”;
statusValue = “Inactive ; “2” ;
statusValue = “Cancelled” ; “3”
)

There are other ways to do this calc, but this is more ‘clear’....

Put the statusValue ‘behind’ the Em_Status on the layout, Em_Status not enterable and out of the tab order.

Users will tab/click into the statusValue, made their choice in the popuplist and the according number will be displayed in Em_Status....

There are other ways to accomplish this, but with this one you learn to apply the same technique for different purposes :)

HTH

JW
 
Cooler would be if you could replace your original data with the formatted data, Active by 1 Inactive by 2 etc in the same field.....

Want to go for that ?

Let’s try it...
You need 5 fields :
Em_State , look-up by valuelist
Em_Mask_cn, calc with Case statement
serial_n, auto enter autonumber, increment 1
modTime, modification time
serialTrigger_cn, Case(modTime; serial_n; serial_n)

and a self relationship, serialTrigger_cn ::serial_n


The key to this solution is a lookup. The field you want to be formatted will be the lookup. In this case, that field is the Em_State field. The only drawback is you need to exit the record by typing the Enter key on the numeric keypad or moving to another record, you can’t just tab to another field. So it depends how your interface/layout is built.

The lookup is based on the match between the serialTrigger_cn and the serial_n field.

Any time the modTime field changes, the calculation reevaluates. The modTime auto-enters the modification time. That means the time updates everytime the record is exited, if a change has been made to a field on the record. Since the calculation returns the serial_n value whether the result is true or false, the calculation value does not actually change. However, the reevaluation of the calculation is enough to trigger the lookup. The lookup is then able to grab the filtered Em_State from the Em_Mask_cn field.
If you want a samplefile leave a mailaddress....

HTH

JW
 
Another possibility, but that's the other way round, is to use the 'Choose' function....

Em_State = 1, 2 or 3

Em_Mask = calc = Choose (Em_State;"Not applicable";"Active";"Inactive";"Cancelled")

See what you can do with that....

It was just a thought....:)

JW
 
Salut Jean

I will look at your solution, but it seems very complicated to me.

I'll give you some feed back tomorrow.

Thanks

Nro

PS : One star for you
 
It's a lot simpler to set up a separate file holding just three records of two fields. The fields are StatNum (Contents are 1, 2 and 3) and StatText (Contents Active,Inactive and Cancelled.)
Define the valuelist as from that file. You can show both fields.
I think that, in V7, you can use a table to do the same.

Cheers,
Paul J.
 
In a way you're right Paul, and I use that technique too.

I wanted to 'kill 2 birds with one stone' since Nro seems to be a new user.
To show that there are more than one solution in FM,more 'things' to use, some calculations, case statement, layout tricks etc...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top