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

Report says I have 2048+ chars when I don't

Status
Not open for further replies.

nkrst1

Programmer
Feb 13, 2001
49
0
0
US
I'm simply adding a little bit of code to a control source in a report, but once I'm done, it keeps saying that I can't have an expression longer than 2,048 characters in control source, which it isn't. You don't have to read this, but if you do a cut and paste, i'm pretty sure that you'll find that the character count of this is less than 1,500 chars. It's driving me nuts. All I want it do is have the first name of a nun follow "Sister" or "Sr." rather than the last.

=Trim("Dear " & (IIf([Enter Contact Type, if any, to address] Is Null,[sName],(IIf([Enter Contact Type, if any, to address]="Principal",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Principal")),(IIf([Enter Contact Type, if any, to address]="financial administrator",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Financial Administrator")),(IIf([Enter Contact Type, if any, to address]="admissions director",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Admissions Director")),(IIf([Enter Contact Type, if any, to address]="main contact" Or [Enter Contact Type, if any, to address]="checks Addressee",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Principal")))))))))))) & ":")

Any help would be much appreciated.

-n-
 
n,


Here's a nifty idea. In your form, make a new button and paste all that code into a msg box.

Sub ButtonClick()
MsgBox ("Dear " & (IIf([Enter Contact Type, if any, to address] Is Null,[sName],(IIf([Enter Contact Type, if any, to address]="Principal",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Principal")),(IIf([Enter Contact Type, if any, to address]="financial administrator",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Financial Administrator")),(IIf([Enter Contact Type, if any, to address]="admissions director",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Admissions Director")),(IIf([Enter Contact Type, if any, to address]="main contact" Or [Enter Contact Type, if any, to address]="checks Addressee",(IIf([TypeName] Is Not Null,(IIf([DearLine] Is Not Null,[DearLine],[Salutation] & " " & IIf(InStr([Salutation], "sister") or InStr([Salutation],"sr"),[FirstName],[LastName]))),"Principal")))))))))))) & ":")
End Sub

NOw click this button and se what the msg box produces. Count away my friend. See if it is too long.

LEARN TO LOVE MESSAGE BOXES! They are so helpful in seeing if you've written code correctly.

-Josh

------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
The result will be fine... it won't be too long, but it says that the expression is too long, but I cut and pasted it into word and did a character count which said that it was under 2,048 chars (can't remember now, but it was about 1,050 or so). Why does it say that there are too many chars?

thanks for your help...
 
Ooooooooooooooooooooooooooh!!!!!!!!

The problem is that you're trying to put too many words into the control source box - in properties. I gotchya.
I just pasted that into word and I got 1200 characters with spaces. Yes, that is below 1500.

Maybe we can work around this by setting up a string value, pasting your long text in there and then having the control source equal this new string name.

What do you think? If yes, then Ill help you figure out how to do it. I'm not sure if the Control Source can call a string value. I think you'd do something up in the top of your class module (up by Explicit commands and stuff, before any sub's start)

Public LongChars as String
Set LongChars = all your crazy text here minus that equal sign.

Then subs start.

Then maybe in Control Source properties put =LongChars

Not sure, but something like that. Can anyone else give a hand?

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Tried it, did not like it.
I could not even get it to display properly in a message box. Heck I could not get a variable to even store it.
A2K kept giving me compile error after compile error as soon as I tried to tie it.

Anyway, it appears that that won't work.

Additionally, I did try to change the control source via code using an assigned variable and it would not work. I had to assign the specific text to the control source for it to work properly.

This one is getting interesting....

More to come!
Rhonin
"too many questions, too little time..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top