RET Posted March 11, 2004 Posted March 11, 2004 I have been trying to get this to work and looking back on this forum I saw a few example of how to do this but was unable to make it work. Lets see I need a field to be a Social Security Number field. I need to just type in my field nine number and have to format it automatically with dashes after the 3rd number and 5th. Ok lets just say my field is called
spb Posted March 11, 2004 Posted March 11, 2004 This sort is common problem. You need two fields, one to enter the data and a separate calculation field to reformat the data. Ideally they should be the same field, but if you try to enter data into a calculation field you'll get a "field cannot be modified" error. Traditionally, FM developers put the data entry field on a data entry layout, and use the calculation field wherever the SSN needs to be displayed or printed. There are various forms of workaround, such as placing the calc field directly on top of the entry field, and set the calc field to not allow entry. When the user is "in" the twin fields, he will be only "in" the entry field. Once data is entered and field is exited, then the superimposed calc field appears, giving the impression the hyphens just appeared. The drawback with this technique is that you can't click into the field with the mouse. You have to have a script leave you in the field (Go To Field function). I think you can set the tab order and tab into the field, though I haven't tried this. If this is what you want to do, calc below. Make sure both fields are text. The entry field (SSN) is defined as a basic text field, and the calc field (c_SSN) is defined to have result = text. Otherwise, SSNs that begin with zeros will have them stripped. The c_SSN calc is: Left(SSN, 3) & "-" & Middle(SSN, 4, 2) & "-" & Right(SSN, 4) I've been following the discussion on the new FM 7, and it looks like you will able to do this more handily with one field using 7. Enter the string of numbers, and when you exit the field the hyphens snap into place. See the discussion on field formatting relating to phone numbers in new FM 7 discussion group. Steve Brown
CyborgSam Posted March 11, 2004 Posted March 11, 2004 Steve-> > The drawback with this technique is that you can't click into the field with the mouse. I can click into fields using this method. Make sure the calculation field is formatted so Allow Data Entry is turned off, then the click goes through the the object further back (the entry field). FM7 puts this method in the archive...
-Queue- Posted March 11, 2004 Posted March 11, 2004 You can use the modtime trigger technique to lookup the calculated mask and overwrite the original field, if you wish to avoid the "data looks like crap until exiting the record" syndrome.
spb Posted March 12, 2004 Posted March 12, 2004 Reply to CyborgSam: You are absolutely right. Making the calc field not allow entry *does* force a mouseclick into the underlying field. I've never used this, so I didn't realize this. At any rate, doing this will set up the SSN field exactly the way RET wants it to behave, if I'm interpreting him correctly. Steve Brown
Recommended Posts
This topic is 7630 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now