#error

S

srctr

I have a letter I am creating. I have something wrong and cannot figure it
out.

This gives me an #error
=CanShrinkLines(Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

This works

=CanShrinkLines(Trim(StrConv([First Name],3) & (StrConv(" "+[MI],3)) & " " &
StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

My envelope works great but I don't do the case conversion
=CanShrinkLines(Trim((+[Title]) & " " & [First Name] & (" "+[MI]) & " " &
[Last Name] & (", "+[Suffix])),[Address1],[Address2],Trim([City] & ", " &
[State] & " " & [ZipEC]))

But I need to include the Title if there is one and everything in the table
is uppercase so I need it to use the proper case.

I know that StrConv([FieldName],3) converts the case. I know if I put a +
before the field it is only included if it is not blank. I don't understand
what is wrong.

Help!!
 
C

Clifford Bass

Hi,

How about changing it around to StrConv([Title]+" ") & ...

Clifford Bass
 
S

srctr

No this didn't work
--
cao


Clifford Bass said:
Hi,

How about changing it around to StrConv([Title]+" ") & ...

Clifford Bass

srctr said:
I have a letter I am creating. I have something wrong and cannot figure it
out.

This gives me an #error
=CanShrinkLines(Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

This works

=CanShrinkLines(Trim(StrConv([First Name],3) & (StrConv(" "+[MI],3)) & " " &
StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

My envelope works great but I don't do the case conversion
=CanShrinkLines(Trim((+[Title]) & " " & [First Name] & (" "+[MI]) & " " &
[Last Name] & (", "+[Suffix])),[Address1],[Address2],Trim([City] & ", " &
[State] & " " & [ZipEC]))

But I need to include the Title if there is one and everything in the table
is uppercase so I need it to use the proper case.

I know that StrConv([FieldName],3) converts the case. I know if I put a +
before the field it is only included if it is not blank. I don't understand
what is wrong.

Help!!
 
C

Clifford Bass

Hi,

Just tested your original statement and it works for me in Access 2007.
You may want to add error handling to the CanShrinkLines() function, see if
there error is happening there. If no errors in the function, try putting
just the Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (", "+[Suffix])) part
in a query to see if you can isolate the problem. Maybe removing one item at
a time until it works. Then you can look at the part the is causing the
error.

Hope that helps,

Clifford Bass
 
S

srctr

I am not sure want you mean by add error handling to CanShrinkLines()
function. I have isolated the problem to the [Title] field and the StrConv
command. As I stated in my first message the whole thing works with no
errors without any StrConv done. I have tried stripping each component out
and discovered when I remove the Title part I don't get the error. I am not
sure want else I can do to try to isolate it. Could it have something to do
with the fact that my Title field includes a period (i.e. MR. , MRS. , MR. &
MRS., REV. , DR.) - Does that interfere with the StrConv function? I put the
Title field on the letter all by itself - it shows me the field without error
until I add the StrConv function.
--
cao


Clifford Bass said:
Hi,

Just tested your original statement and it works for me in Access 2007.
You may want to add error handling to the CanShrinkLines() function, see if
there error is happening there. If no errors in the function, try putting
just the Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (", "+[Suffix])) part
in a query to see if you can isolate the problem. Maybe removing one item at
a time until it works. Then you can look at the part the is causing the
error.

Hope that helps,

Clifford Bass

srctr said:
No this didn't work
 
C

Clifford Bass

Hi,

Hmm.... I think I see the issue. +[Title] when title is null gives
null and StrConv() does not like null. Try Trim((StrConv([Title] & " ",3))
instead.

To add error handling to a function you can do something like this:

Public Function MyFn(strParam1 As String) As Variant

On Error GoTo Handle_Error

' normal function coding

Exit_Function:
Exit Function

Handle_Error:
MyFn = "Error #" & Err.Number & ": " & Err.Description
Resume Exit_Function

End Function

Clifford Bass
 
S

srctr

Okay, I don't think that is the problem. I tried your solution and I am
still getting the #error. Also I have another letter that uses the string I
want and it works. The two letters that I have created one is based on
sending a letter for an annual appeal, the second is a Thank you letter when
they send us a donation. Both are base on the same 2 tables with the Thank
you letter have a third table also in the query.

The thank you letter works and has exactly what I want
=CanShrinkLines(Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

The Appeal letter when I use the above doesn't work so I had to take the
Title part out. It has the following instead
=CanShrinkLines(Trim(StrConv([First Name],3) & (StrConv(" "+[MI],3)) & " " &
StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

I cannot for the life of me figure out why it won't work, where the problem
is. What other thinks should I be looking for?
--
cao


Clifford Bass said:
Hi,

Hmm.... I think I see the issue. +[Title] when title is null gives
null and StrConv() does not like null. Try Trim((StrConv([Title] & " ",3))
instead.

To add error handling to a function you can do something like this:

Public Function MyFn(strParam1 As String) As Variant

On Error GoTo Handle_Error

' normal function coding

Exit_Function:
Exit Function

Handle_Error:
MyFn = "Error #" & Err.Number & ": " & Err.Description
Resume Exit_Function

End Function

Clifford Bass

srctr said:
I am not sure want you mean by add error handling to CanShrinkLines()
function. I have isolated the problem to the [Title] field and the StrConv
command. As I stated in my first message the whole thing works with no
errors without any StrConv done. I have tried stripping each component out
and discovered when I remove the Title part I don't get the error. I am not
sure want else I can do to try to isolate it. Could it have something to do
with the fact that my Title field includes a period (i.e. MR. , MRS. , MR. &
MRS., REV. , DR.) - Does that interfere with the StrConv function? I put the
Title field on the letter all by itself - it shows me the field without error
until I add the StrConv function.
 
C

Clifford Bass

Hi,

That is odd. Something is different and causing the trouble. Is this
happening on the exact same name/address? Did you add in the error handling
so that you could get a better error message then just "#Error"? Try putting
a break point in the CanShrinkLines function and when it breaks, hover your
cursor over each of the values being used to see what they are. Press
Shift-F8 to step through each part until it bombs to see what exactly is
happening.

Good Luck,

Clifford Bass

srctr said:
Okay, I don't think that is the problem. I tried your solution and I am
still getting the #error. Also I have another letter that uses the string I
want and it works. The two letters that I have created one is based on
sending a letter for an annual appeal, the second is a Thank you letter when
they send us a donation. Both are base on the same 2 tables with the Thank
you letter have a third table also in the query.

The thank you letter works and has exactly what I want
=CanShrinkLines(Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

The Appeal letter when I use the above doesn't work so I had to take the
Title part out. It has the following instead
=CanShrinkLines(Trim(StrConv([First Name],3) & (StrConv(" "+[MI],3)) & " " &
StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

I cannot for the life of me figure out why it won't work, where the problem
is. What other thinks should I be looking for?
--
cao


Clifford Bass said:
Hi,

Hmm.... I think I see the issue. +[Title] when title is null gives
null and StrConv() does not like null. Try Trim((StrConv([Title] & " ",3))
instead.

To add error handling to a function you can do something like this:

Public Function MyFn(strParam1 As String) As Variant

On Error GoTo Handle_Error

' normal function coding

Exit_Function:
Exit Function

Handle_Error:
MyFn = "Error #" & Err.Number & ": " & Err.Description
Resume Exit_Function

End Function

Clifford Bass

"srctr" wrote:
 
S

srctr

No I didnt' add the error handling because I really don't know where or how
to do it. Also I don't know how to do what you just suggested with
breakpoints. Could you give me more specific instruction? Thanks

--
cao


Clifford Bass said:
Hi,

That is odd. Something is different and causing the trouble. Is this
happening on the exact same name/address? Did you add in the error handling
so that you could get a better error message then just "#Error"? Try putting
a break point in the CanShrinkLines function and when it breaks, hover your
cursor over each of the values being used to see what they are. Press
Shift-F8 to step through each part until it bombs to see what exactly is
happening.

Good Luck,

Clifford Bass

srctr said:
Okay, I don't think that is the problem. I tried your solution and I am
still getting the #error. Also I have another letter that uses the string I
want and it works. The two letters that I have created one is based on
sending a letter for an annual appeal, the second is a Thank you letter when
they send us a donation. Both are base on the same 2 tables with the Thank
you letter have a third table also in the query.

The thank you letter works and has exactly what I want
=CanShrinkLines(Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

The Appeal letter when I use the above doesn't work so I had to take the
Title part out. It has the following instead
=CanShrinkLines(Trim(StrConv([First Name],3) & (StrConv(" "+[MI],3)) & " " &
StrConv([Last Name],3) & (",
"+[Suffix])),StrConv([Address1],3),StrConv([Address2],3),Trim(StrConv([City],3) & ", " & [State] & " " & [ZipEC]))

I cannot for the life of me figure out why it won't work, where the problem
is. What other thinks should I be looking for?
--
cao


Clifford Bass said:
Hi,

Hmm.... I think I see the issue. +[Title] when title is null gives
null and StrConv() does not like null. Try Trim((StrConv([Title] & " ",3))
instead.

To add error handling to a function you can do something like this:

Public Function MyFn(strParam1 As String) As Variant

On Error GoTo Handle_Error

' normal function coding

Exit_Function:
Exit Function

Handle_Error:
MyFn = "Error #" & Err.Number & ": " & Err.Description
Resume Exit_Function

End Function

Clifford Bass

"srctr" wrote:
 
C

Clifford Bass

Hi,

Sure. Open up the module where you put the CanShrinkLines function.
At the top of the function, just below it's declaration add this line:

On Error GoTo Handle_Error

That line tells it that you are going to handle any errors yourself,
rather than the system. It says when there is an error go to the section
that starts with a line label of Handle_Error. At the bottom of it, just
before the End Function line add these lines:

Exit_Function:
Exit Function

Handle_Error:
CanShrinkLines = "Error #" & Err.Number & ": " & Err.Description
Resume Exit_Function

The first two lines are a line label and code that tells the function
to exit; do not go any further. In the last two lines it assigns the message
"Error #nnn: Text of error" to the function name, which is how you tell it to
return that value from the function. Then is says to resume working at the
Exit_Function label. This is useful if you have other processing in that
part of the function. The Resume statement also clears the error status back
to "no error" so that other code that checks for errors will not get
triggered, unless that code also causes an error.

Now, when you run your report, you will hopefully get a more meaningful
message than the generic "#Error".

To add a break point in the code click in the margin area to the left
of the code line where you want to break. You will see a large dot. If the
line you do that to has code that spans multiple lines, it will place dots on
all of the lines. Then when the code gets to that point, it will stop and
display the code window. Once there you can hover your cursor over various
variables to see their contents and you can use things like F8 and Shift-F8
to step through the code a line at a time. See the Debug and Run menus for
all the possibile options.

For more information you can search for "error handling" and
"breakpoint" and "tracing" in the VBA Editor's online help.

Hope that helps,

Clifford Bass
 
M

margarida casteli

srctr said:
I am not sure want you mean by add error handling to CanShrinkLines()
function. I have isolated the problem to the [Title] field and the
StrConv
command. As I stated in my first message the whole thing works with no
errors without any StrConv done. I have tried stripping each component
out
and discovered when I remove the Title part I don't get the error. I am
not
sure want else I can do to try to isolate it. Could it have something to
do
with the fact that my Title field includes a period (i.e. MR. , MRS. , MR.
&
MRS., REV. , DR.) - Does that interfere with the StrConv function? I put
the
Title field on the letter all by itself - it shows me the field without
error
until I add the StrConv function.
--
cao


Clifford Bass said:
Hi,

Just tested your original statement and it works for me in Access
2007.
You may want to add error handling to the CanShrinkLines() function, see
if
there error is happening there. If no errors in the function, try
putting
just the Trim((StrConv(+[Title],3)) & " " & StrConv([First Name],3) &
(StrConv(" "+[MI],3)) & " " & StrConv([Last Name],3) & (", "+[Suffix]))
part
in a query to see if you can isolate the problem. Maybe removing one
item at
a time until it works. Then you can look at the part the is causing the
error.

Hope that helps,

Clifford Bass

srctr said:
No this didn't work
 
S

srctr

Sorry, haven't look at post recently. I will try your idea about Error
handling for future problems. I actually did resolve the problem just this
morning. For some reason last night I suddenly thought about labels for the
fields and text boxes. I remembered that if anything has the same name as a
field it will give you an error. This morning I checked my report again and
sure enough one of the boxes was called Title. I changed it's name, put back
title in the address box and viola!!! My report now works. Sometimes it is
the simpliest thing.

Thanks for all your help.
 
C

Clifford Bass

Hello,

Technically, a control with the same name as a (its) field should work.
However, I have run into troubles so as a matter of course, I rename the
controls so they are distinct from the field names.

Glad to help. You are welcome!

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top