home *** CD-ROM | disk | FTP | other *** search
- Crystal Report / MS Access Time Formats
-
- Date: 4/23/94
- Author: Thomas Becker
- Compuserve ID: 73473,1363
-
- Subject: Format of MS Access Time fields in Crystal Reports
-
- Crystal Report 2.0 (packaged with VB Pro 3.0) does not handle Time
- formatting for MS Access fields defined as "Date/Time". Crystal Report Pro
- 3.0 will handle Time formatting for MS Access ONLY if the database is
- accessed via ODBC.
-
- I have developed three Crystal Reports formulas that will format Time from
- an MS Access database in the following formats:
-
- Format FileName
- ------ --------
- 12:00 AM/PM Time_1.txt
- 24:00 Time_2.txt
- 24:00:00 Time_3.txt
-
- The only catch is, the MS Access Time field must be defined as a DOUBLE (not
- Date/Time). This is not a problem if you maintain your Date and Time fields
- on your database as separate fields. These formulas will NOT work for
- fields that are used for Date/Time Stamps (Date and Time in the same field).
- The reason is, that Crystal Reports will no longer recognize the Date part
- of the field as a Date (and I have not, and probably will not provide a
- formula that will convert a DOUBLE to a Date field).
-
- I have provided three text files for the Time format formulas, as listed
- above. These formulas should work in Crystal Reports 2.0 or 3.0 (Pro or
- Standard).
-
- Following are the steps to install into Crystal Reports:
-
- 1. Run Crystal Reports Report designer.
- 2. Load an existing report or start a new one.
- 3. Minimize Crystal Reports down to an icon.
- 4. Open a text editor (like Windows Note Pad).
- 5. Load the desired Time Format Text file (Time_1.txt, Time_2.txt,
- or Time_3.txt).
- 6. Highlight all text in the file and Copy to the Clipboard.
- 7. Double click on the Crystal Reports icon to re-activate Crystal
- Reports.
- 8. Select Insert|Formula from the main menu.
- 9. Assign a new formula name and press enter.
- 10. Press Shift+Insert to paste the Time format text into your
- formula.
- 11. On the 4th line of the formula is a database field name
- "{Time.Time}". Change this field name to your Time field name.
- 12. Click the "Accept" button and place the field on your report.
-
- You will need to create a formula for each Time field on your report.
-
- The other concern with changing your MS Access Time fields to DOUBLE, is
- how do you handle these field in your VB program. Most of my Time fields
- are updated and displayed using TrueGrid. TrueGrid will handle a Time field
- in "Date/Time" or "DOUBLE" format equally well. Just set the properties
- Format to "hh:mm AM/PM" or "hh:mm:ss" or what ever.
-
- For a Text Box, assign the "TEXT" property of the text box to a Format,
- for example:
-
- Text1.Text = Format(t#,"hh:mm AM/PM")
- or
- Text1.Text = Format(Data1.Recordset("Time"),"hh:mm AM/PM")
-
- If you are currently using a bound Text box, you will need to change it to
- unbound and place the second example above in the Data Control Reposition
- Event.
-
- This isn't the best answer, but it may help until Crystal Services gets it's
- act together and provides Time Formatting for MS Access.
-
- Enjoy,
- Tom