Newsgroup: it.comp.lang.visual-basic
Titolo: [?] Crystal Report non stampa gli orari ?

Salve, il mio problema è questo:
ho un report (generato con CR) che ha come origine una tabella
temporanea (in un file Access) creata di volta in volta con una SELECT
INTO
Va tutto bene tranne un campo contenente un orario, al posto del quale
viene SEMPRE stampata la data 30/12/99...
A voi è mai capitato ? E' un bug di CR ?
Grazie
-= Wolf =-

 viene SEMPRE stampata la data 30/12/99...
Magari il campo _dovrebbe_ contenere un orario ma è vuoto, oppure zero.
Il risultato è proprio quello, prova:
Debug.Print Format(0, "dd/mm/yy")
----> 30/12/99
Bye, G.
--
---------------------------------------------
    Le risposte alle tue domande le trovi sul
    Sito Comune di questo NewsGroup:
 
http://www.murialdo.it/it_lang_vb
---------------------------------------------
Real E-address: 
gaet...@hotmail.com

Grazie
Fatta la verifica che ti suggerisce Paperino, ossia che effettivamente nel
tuo campo data sia correttamente memorizzato un orario, fai in questo modo :
Menu File ==> Report Option
Deseleziona la checkBox : Convert Date-time to Date.
Ciao
Ven.

----> 30/12/99
No, i dati ci sono, è solo che li stampa male. Hai visto come sono i
campi data/ora in Access, devi specificare "Ora breve" per fargli
capire che formato deve avere l'orario. Quando creo la tabella
temporanea, però, questa definizione si perde, resta solo un campo
data/ora senza specifiche... non so se sia questo il problema =((
Wolf

...

Il problema è noto da tempo perchè le versioni di CR data in bundle con VB
non supportano il formato HH:MM:SS.
Le soluzioni sono:
a) ti procuri la versione professional di CR
b) molto più economicamente, utilizzi delle formule come queste:
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
------------------------------------------------------------------
// Time Format for CRYSTAL Reports (12:00 AM/PM format)
//
// Convert MS ACCESS Time to Whole Number
NumberVar TotWholeNbr:={Time.Time}*100000000;
// Calculate Hours
NumberVar Hours:=Truncate(TotWholeNbr/4166666.64);
// Calculate Minutes
NumberVar Mins:=Truncate((TotWholeNbr-(Hours*4166666.64))/69444.444);
// Set AM/PM String
If Hours>=12 Then
  StringVar AMPM:="PM";
If Hours<12 Then
  StringVar AMPM:="AM";
If Hours=0 then
  Hours:=12;
// If past 13:00, adjust hours
If Hours>12 Then
  Hours:=Hours-12;
// Set Hour String
If Hours<10 Then
  StringVar HH:="0"+ToText(Hours)
Else
  StringVar HH:=ToText(Hours);
// Set Minute String
If Mins<10 Then
  StringVar MM:="0"+ToText(Mins)
Else
  StringVar MM:=ToText(Mins);
// Output Time
HH[1 to 2]+":"+MM[1 to 2]+" "+AMPM[1 to 2];
------------------------------------------------------
// Time Format for CRYSTAL Reports (24:00 format)
//
// Convert MS ACCESS Time to Whole Number
NumberVar TotWholeNbr:={Time.Time}*100000000;
// Calculate Hours
NumberVar Hours:=Truncate(TotWholeNbr/4166666.64);
// Calculate Minutes
NumberVar Mins:=Truncate((TotWholeNbr-(Hours*4166666.64))/69444.444);
// Set Hour String
If Hours<10 Then
  StringVar HH:="0"+ToText(Hours)
Else
  StringVar HH:=ToText(Hours);
// Set Minute String
If Mins<10 Then
  StringVar MM:="0"+ToText(Mins)
Else
  StringVar MM:=ToText(Mins);
// Output Time
HH[1 to 2]+":"+MM[1 to 2];
---------------------------------------------------------------------
// Time Format for CRYSTAL Reports (24:00:00 format)
//
// Convert MS ACCESS Time to Whole Number
NumberVar TotWholeNbr:={Time.Time}*100000000;
// Calculate Hours
NumberVar Hours:=Truncate(TotWholeNbr/4166666.64);
// Calculate Minutes
NumberVar Mins:=Truncate((TotWholeNbr-(Hours*4166666.64))/69444.444);
// Calculate Seconds
NumberVar
Secs:=Truncate((TotWholeNbr-((Hours*4166666.64)+(Mins*69444.444)))/1157.4074
);
// Set Hour String
If Hours<10 Then
  StringVar HH:="0"+ToText(Hours)
Else
  StringVar HH:=ToText(Hours);
// Set Minute String
If Mins<10 Then
  StringVar MM:="0"+ToText(Mins)
Else
  StringVar MM:=ToText(Mins);
// Set Seconds String
If Secs<10 Then
  StringVar SS:="0"+ToText(Secs)
Else
  StringVar SS:=ToText(Secs);
// Output Time
HH[1 to 2]+":"+MM[1 to 2]+":"+SS[1 to

b) molto piů economicamente, utilizzi delle formule come queste:
Grazie mille, Stefano, mi hai levato dalla cacca piů scura (per usare
un francesismo) =))
A buon rendere ! =))
Wolf