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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting question

Status
Not open for further replies.

asm338s

Programmer
Jul 16, 2001
135
US
Hi:
I used one table to build a form and put values in text boxes. The dates stored in the table are in yy/mm/dd format, but I want them to be displayed in mm/dd/yy format. I did the something similar to this in another form in a combo box using SUBSTR(). I don't know in which property/method for the text box i should write the code.

Thanks

P.S.: please also look at my 'object formName not found' thread.
 
Hi
You can have a global command to set the date format
SET DATE AMERICAN
This will display all the dates in MM/DD/YY format.
This command you can put in the init of the form or in the initial Main.Prg (more ideal place.. along with other SET commands.) This will solve your problem in all date places.

Hope this helps you :) ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
I am not using a date field to store dates in my tables. It is a character field in the tables. I have been trying to do substr() on the textbox value, but I don't know know under what property or method should i do that, so that the textBox retains the formatting style even when you browse the records in the form. I did it using a substr() for a cbo. box.

Thanks
 
You can use the INPUTMASK property of the text box.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Hi Ramani:

I put the substr() in the input mask of the text box and set format property to 'r'. when the form loads instead of showing the formatted data in the text box, the text box actually shows the substr() function text.

Thanks
asm338s
 
This is the code in the InputMask:

substr(table.field,3,2) + '/' + substr(table.field,5,2) + '/' + substr(table.field,1,2)

It shows this code when the form loads.

Thanks
 
Hi
The inputmask shall be entered as
99/99/99
Hope this clears the matter :) ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Hi:

Sorry to bug you guys, but I don't think I am making myself clear. The date I have is in yymmdd format. If I put 99/99/99 in the input mask, all that will do is show the date as yy/mm/dd(add backslashes). I want the date to appear as mm/dd/yy.

Thanks
 
I'm curious about the reason you're formatting the date as text for this particular field. It seems like you might be trying to do something like sorting/ordering on this field. If that's the case, you can use a true date field and use DTOS(myDate) in your index command. Even though the date is stored as mm/dd/yyyy the DTOS function will treat it as yyyymmdd. I hope this helps.
 
You can place the following into the Init of the textbox:

this.value = substr(table.field,3,2) + '/' + substr(table.field,5,2) + '/' + substr(table.field,1,2)

Jim
 
I guess you want to update the textbox's value while you transverse your table. I suggest this: the same code that Jim has written but located in the Refresh method of the textbox:

TextBox::refresh
this.value = substr(table.field,3,2) + '/' + substr(table.field,5,2) + '/' + substr(table.field,1,2)

X-)
Take away all the buzz of this biz and what do you get? 01000100101010...
 
I tried this earlier. I used both this.value and thisform.textbox.value, but for some odd reason it is modifying the values in the table instead of just formatting them in the form. It seems like a small problem but I am getting tired of trying to fix it.

I appreciate all your help and patience.
 
Set the ControlSource of the textbox to "None", and put the code in the Refresh method as suggested by CBU64.

Jim
 
Thanks Jim. That problem had been bugging me for a while. I have another thread going called 'object formName not found' . It has been out there for a while and still not resolved, so if you wanna take a look at that.

Thanks

asm338s
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top