Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I train people in ACCESS. I make sure they know about these forums, give them some training on how to use the site, and have a shortcut to it on their PC's..."

Geography

Where in the world do Tek-Tips members come from?

error with formula to zero fill a field if no data is presentHelpful Member!(2) 

timISST (MIS)
3 Jul 12 8:53
IF (ISNULL({date)) = TRUE
then "00000000"
else {date};

Gives me the error of a string is expected here at the second date ( they are date fields) tried converting to str and when i did that it gives me the bolean str number date error. Any ideas?
SkipVought (Programmer)
3 Jul 12 9:25

hi,

Why would you want TEXT in a Date field? Dates are NUMBERS!

CODE

IF (ISNULL({date)) = TRUE
then DateSerial(1900,0,0)
else {date}; 
BTW, I would not use date as a field name as it is a reserve word.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

Helpful Member!  SkipVought (Programmer)
3 Jul 12 9:27


and this is better

CODE

IF ISNULL(date)
then DateSerial(1900,0,0)
else date; 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

timISST (MIS)
3 Jul 12 9:29
this is a formatting requirement for a report that has to be done as all zeros if the field is blank if there is a date is has to be shown as 20120301 and if no data present has to be 00000000
SkipVought (Programmer)
3 Jul 12 9:34
Then you must convert the date value to TEXT: ToText

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

timISST (MIS)
3 Jul 12 9:47
do you mean something like this?

ToText ({date});
IF IsNull ({date})= true
then '00000000'
else {date};
SkipVought (Programmer)
3 Jul 12 10:19

CODE

IF IsNull ({date})
then '00000000'
else ToText ({date}); 
BTW IsNull ({date}) is either TRUE or FALSE

When IsNull ({date}) is FALSE then ELSE is executed

When IsNull ({date}) is TRUE then the THEN is executed

If IsNull ({date}) = TRUE is redundant.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

timISST (MIS)
3 Jul 12 10:31
AWESOME only thing is how would i change 6/2/2012 over to the 20120602? I cannt use the display string to do that
Helpful Member!  IanWaterman (Programmer)
3 Jul 12 11:12
ToText ({date}, 'yyyyMMdd');

Ian
timISST (MIS)
3 Jul 12 11:23
AWESOME THANK YOU BOTH!!!
timISST (MIS)
3 Jul 12 16:05
Is there a way to designate field lengths? all of this is a report that has fields that may or may not have data and filler fields that have to be there to be read by the recieveing party? The zero filled ones I have figured out the blanks I think I know what im doing but wasnt sure if there was a way to tell crystal this field is always x characters and no spaces between.
timISST (MIS)
3 Jul 12 16:11
should have added that im using a lot of formulas in this in case that makes a difference
IanWaterman (Programmer)
4 Jul 12 3:58
Not sure what you mean can you show example of data as is and how you would like it to look.

Ian
timISST (MIS)
5 Jul 12 8:45
I made formulas to lay out like filler fields and such where they may not be data present but the spacing has to be. The issue Im having is I need all the fields touching as to not create undo and unwanted spaces in the report at suggestions?
IanWaterman (Programmer)
5 Jul 12 9:48
If you are exporting to Excel then use vertical guides lines and make sure all fields sap to guides at both ends

Make sure all fields are same height and aligned at top and tightly clamped in section dividers and white space above or below will introduce blank rows.

Ian

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close