Genx Posted June 18, 2006 Posted June 18, 2006 (edited) Um, i really couldn't think of a better topic name . I need a field where a user can enter either a date or text... but i need to be able to identify through calc if its a date or plain text. I was thinking of using If IsValid(GetAsDate(field)) but i'm also thinking that i have to use a date field for this and if i use a datefield for this it will give me an error if plain text is input... Also i'm using a custom dialog here and all three fields are already being used so i cant put any additional indication in (i don't want multiple dialog's). Thanks for any help or suggestions. EDIT: I forgot to mention that the "plain text" will have numbers in it aswell though there will be no "/". Thinking along these lines i'm also thinking that GetAsDate(field)<>"?" would work. ~Genx Edited June 18, 2006 by Guest
Søren Dyhr Posted June 18, 2006 Posted June 18, 2006 IsValid(GetAsDate(field)) I can spot a flaw or discrepancy in the reasoning by thinking of the 30th of february, entered in dateformat is alright but the date as such will cause the bleepers to go on. Also i'm using a custom dialog here and all three fields are already being used so i cant put any additional indication in (i don't want multiple dialog's). Now, it's not clear to me if validation dialogs is the only issue here, but sometimes can you make use of conditional validations by adding a validation field 1 pix in both dimentions as well as having it's borders in the background colour, with disallowed entry. To this field add a calculated validation covering all the field in question, and remember to lift the lower left corner checkbox in the calc'def. saying "Validate only if...." I can only think of few legitimate reasons for landing your self in this limbo... And what about dates in text fields? There may at times be a reason to put a date in a text field. Though at the moment I can’t think of one, it has been done. A date in a text field can be converted to a real date. However, if that field contains dates such as: May 2003, 1.1.04, 2-2-2002, 3/3/03, 4|4|2005, 2001; you face a genuine brain bender. If users are allowed to place dates in a text field, this is exactly the kind of mess you will get. ...and one of those that might be alright could be structures like this: http://previews.filemakermagazine.com/videos/513/DataTagging_full.mov But here is the user promted to cathegorize the type, so you behind the scenes can make a conditional validation. --sd
Genx Posted June 18, 2006 Author Posted June 18, 2006 Hmm perhaps, but in my case users are trained to use the solution and would be instructed to insert only standard format dates. As per the 30 of feburary issue, yes, but i may try implementing: If(Substitute( TextField ; "/" ; "") <> TextField ; //Assume user is trying to enter date, do an isvalid check and if isn't valid return error to script and prompt user if they were trying to enter date ; //assume user is trying to enter text )
Tricky Posted June 18, 2006 Posted June 18, 2006 You can create a global date field. Then, in your script, as the user has put the data into the dialog, set the global to the value of the field you wish to check. Set error capture on, and evaluate the isvalid you mentioned. If not, the value that was put in, is not a date. It seems tricky to me nevertheless, because how can you control how users enter a date? Some might be using the correct syntax with the brackets, some might not enter the year with four digits and stuff like that. I am interested to hear why you want to do this anyway!
Genx Posted June 18, 2006 Author Posted June 18, 2006 Year doesn't need to be included only d/m or dd/m or dd/mm or d/mm, year is assumed to be the current year unless stated otherwise in which case it can be in the format yy. Doing this for contact reminders in my solution, the issue is i'm really out of fields in the custom dialog and i wan't users to be able to schedule a reminder either on a specific date or use a time period such as 1 day, 2 weeks, 3 months, today etc. These are all recalculated in calc field to work out the date but if the user enters a date i need it to sense that the user has entered a date rather than some other value. Btw, setting error capture to on never really occured to me but i'm not sure its detailed enough. ~Genx
Tricky Posted June 18, 2006 Posted June 18, 2006 And, just as an afterthought: you know what assuming can do, right? It makes an "ass" out of "u" and "me"... ;-) Hope the first syllable is not changed by the automatic code of conduct rules...
Genx Posted June 18, 2006 Author Posted June 18, 2006 Yes, which is why they get prompted as to whether they were trying to enter a date . I must admit i've never heard that one before though lol.
Mike D. Posted June 19, 2006 Posted June 19, 2006 but in my case users are trained to use the solution Genx, this is a little naive. Just because they are trained today, doesn't mean they will always follow directions. Users will always find a different way to use the solution than you anticipated. I learned that one the hard way... Mike
Genx Posted June 20, 2006 Author Posted June 20, 2006 a) i really don't think it's naieve, its not as if 17/3/06 or 17/3 isn't a standard format in australia. as a second precaution they are shown in the custom dialog the appropriate format c) third in terms of the textual values they are restricted to only about 15 values that they can enter ~Genx
Recommended Posts
This topic is 6730 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