This topic is locked

date format_wiev as

1/14/2008 5:19:36 AM
ASPRunnerPro General questions
U
uludag author

Hi,

My Ms Access file stores the dates as ordinary text. So it appears 20080115. I would like asprunner project to make it transform to 15.01.2008 (dd.mm.yyyy) in view, edit or add menu while Ms Access file remains the same, namely 20080115. Is this transformation (view as) possible with asprunner project?

Sincerely,

Uludag.

Sergey Kornilov admin 1/15/2008

You can use "View as" type "Custom" to convert 20080115 string to 15.01.2008 manually.
Check VBScript function Mid().
You can also use BeforeAdd/BeforeEdit event to convert it back to your format before writing it to the database.

U
uludag author 1/16/2008

Hi,
I wrote several questions on this forum, and I got really helpful answers. I would like to thank Admin and Alexey for their valuable support.
Asprunner is really wonderful program, and the support the admins provide here enriches the program. Many thanks for the program and for your support.
However, I am so sorry to say that I could not understand your last direction above.
What am I supposed to do to convert yyyymmdd to dd.mm.yyyy on "custom" page of "view as".
Secondly, I could not find VBScript function.
Lastly, what is the code I should write or what am I to do on "beforeadd/afteradd".
Thanks again.

U
uludag author 1/21/2008
J
Jane 1/23/2008

Hi,
here is a sample code:

str = Mid(strValue,7,2) & "." & Mid(strValue,5,2) & "." & Mid(strValue,1,4)

strValue = str

Also you need to convert dd.mm.yyyy to yyyymmdd value on the add/edit page (in the Before record added/Before record updated events on the Events tab).

Here is a sample:

str = Mid(dict("FieldName"),7,4) & "" & Mid(dict("FieldName"),4,2) & "" & Mid(dict("FieldName"),1,2)

dict("FieldName") = str


More info about VBScript functions here:

http://www.w3schools.com/vbscript/

U
uludag author 1/24/2008

Thank you very much, Jane.

The code for view as menu is working great. However, I could not manage to make the second code work. I got an error message about OLE DB value.

What did I do wrong? or is the second code above really right?

Sincerely,

U
uludag author 1/30/2008

I could not solve the problem: to convert dd.mm.yyyy to yyyymmdd value on the add/edit page (in the Before record added/Before record updated events on the Events tab).
The code in my "before record updated" is that:

' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form is represented as a 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited

' oldvalues - Scripting.Dictionary object with existing data record content
'********** Custom code ************

' put your custom code here

str = Mid(dict("FieldName"),7,4) & "" & Mid(dict("FieldName"),4,2) & "" & Mid(dict("FieldName"),1,2)

dict("FieldName") = str
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False otherwise


The code in my "before record added" is that:

' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Add form is represented as a 'Field name'-'Field value' pair
'********** Custom code ************

' put your custom code here

str = Mid(dict("FieldName"),7,4) & "" & Mid(dict("FieldName"),4,2) & "" & Mid(dict("FieldName"),1,2)

dict("FieldName") = str
BeforeAdd = True
' set BeforeAdd to True if you like to proceed with adding new record

' set it to False otherwise


Do these codes seem right?

U
uludag author 1/30/2008

Ooopps.

I just figured out that I had not written the real "FieldName". So sorry. It works great.

Many thanks, Jane.