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!

Variable Types

Status
Not open for further replies.

bld21

Technical User
Mar 1, 2010
49
US
I am using crystal reports 2008.

I am receiving the following error: A variable type (for example, 'numberVar') is missing.

I am using the following code for mailing addresses.

Shared shr_addr_1 As String
Shared shr_addr_2 As String
Shared shr_addr_3 As String
Shared shr_city As String
Shared shr_state_cde As String
Shared shr_postal_cde As String

Dim strFullAddress As String

strFullAddress =""

If shr_addr_1 <> "" Then
strFullAddress = strFullAddress + shr_addr_1
End If
If shr_addr_2 <> "" Then
strFullAddress = strFullAddress + Chr(13) + shr_addr_2
End If
If shr_addr_3 <> "" Then
strFullAddress = strFullAddress + Chr(13) + shr_addr_3
End If

If shr_city <> "" AND shr_State_cde = "" AND shr_Postal_cde = "" Then
strFullAddress = strFullAddress + Chr(13) + shr_city
elseif shr_city <> "" Or shr_State_cde <> "" Or shr_Postal_cde <> "" Then
Dim strPostalCode As String
If shr_Postal_cde <> "" Then
'format Postal code
'if {customer_address.country_cde} = "USA" then
if (Mid (shr_Postal_cde, 6, 4) = "") then
strPostalCode = Left (shr_Postal_cde, 5) '+ "-" + "0000"
else
strPostalCode = Left (shr_Postal_cde, 5) + "-" + Mid (shr_Postal_cde, 6, 4)
End If
'else if {customer_address.country_cde} = "CAN" then
' strReturn := Left ({customer_address.postal_cde}, 6);
End If
strFullAddress = strFullAddress + Chr(13) + shr_city + ", " + shr_State_cde + " " + strPostalCode
End If
formula = strFullAddress


Any ideas?
Bruce D.
 
bld21,

Your declaration statements appear to be backwards (to me).

Shared shr_addr_1 As String
Shared shr_addr_2 As String
Shared shr_addr_3 As String
Shared shr_city As String
Shared shr_state_cde As String
Shared shr_postal_cde As String

should be

Shared StringVar shr_addr_1
etc

Hope this helps!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Mike,

I tried that but now I get an error that the remaining text does not appear to be part of the formula and the second line and the rest of the code is highlighted. I copied what is hightlighted below:



Shared Stringvar shr_addr_2
Shared Stringvar shr_addr_3
Shared Stringvar shr_city
Shared Stringvar shr_state_cde
Shared Stringvar shr_postal_cde

Dim strFullAddress As String

strFullAddress =""

If shr_addr_1 <> "" Then
strFullAddress = strFullAddress + shr_addr_1
End If
If shr_addr_2 <> "" Then
strFullAddress = strFullAddress + Chr(13) + shr_addr_2
End If
If shr_addr_3 <> "" Then
strFullAddress = strFullAddress + Chr(13) + shr_addr_3
End If

If shr_city <> "" AND shr_State_cde = "" AND shr_Postal_cde = "" Then
strFullAddress = strFullAddress + Chr(13) + shr_city
elseif shr_city <> "" Or shr_State_cde <> "" Or shr_Postal_cde <> "" Then
Dim strPostalCode As String
If shr_Postal_cde <> "" Then
'format Postal code
'if {customer_address.country_cde} = "USA" then
if (Mid (shr_Postal_cde, 6, 4) = "") then
strPostalCode = Left (shr_Postal_cde, 5) '+ "-" + "0000"
else
strPostalCode = Left (shr_Postal_cde, 5) + "-" + Mid (shr_Postal_cde, 6, 4)
End If
'else if {customer_address.country_cde} = "CAN" then
' strReturn := Left ({customer_address.postal_cde}, 6);
End If
strFullAddress = strFullAddress + Chr(13) + shr_city + ", " + shr_State_cde + " " + strPostalCode
End If
formula = strFullAddress
 
place a semi-colon at the end of logical lines.

ie:
Shared Stringvar shr_addr_2;
Shared Stringvar shr_addr_3;
Shared Stringvar shr_city;
etc;
etc;
etc;
 
Looks like the code is in Basic Syntax, but the formula editor is looking for Crystal Syntax. If so, then no semi-colons. That is for Crystal Syntax.
 
Yes, that was it, I missed that too.
Thanks to everyone, this is a great resource!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top