I have a subreport which is based on a query. This query has a "calculated" field which is as follows:
Readdress: [Street]&" "&[City]&", "&[State]&" "&[Zip]
The Street, City, State, and Zip fields are within the same query. This combines the above fields to give me a format such as "101 W. 2nd Ave. Aimes, Iowa 12345". This field appears in a subreport which is based on the above query. If all of the above fields have values in the table, the formatting on the report is fine. If, for instance, no street address is in the table, then on the report I have two "spaces" followed by the rest of the query. Similarly, if none of the fields in the table have values, I only have a comma in the field on the subreport. My question is how do I eliminate preceding "spaces" or eliminate the comma to leave a blank field in the subreport. I don't want to make the fields required in the data entry form for the table because this information is often not available. I have tried variations of the following in code for the subreport as well as the main report, but I get an error that I can't assign a value to this field:
If Left(me.readdress,2)=" " then
me.readdress=right(me.readdress,(len(readdress)-2))
end if
I know this would only solve my problem of two preceding "spaces", but I figured if this worked, I could work out the rest. I also don't want to eliminate null values for the above fields in the query because I think that would eliminate records in the query (such as a student's name and exam score) that I need to include in the report (subreport). Any suggestions on this? Is it coding I need in the report or something in the query? Thanks in advance!
Readdress: [Street]&" "&[City]&", "&[State]&" "&[Zip]
The Street, City, State, and Zip fields are within the same query. This combines the above fields to give me a format such as "101 W. 2nd Ave. Aimes, Iowa 12345". This field appears in a subreport which is based on the above query. If all of the above fields have values in the table, the formatting on the report is fine. If, for instance, no street address is in the table, then on the report I have two "spaces" followed by the rest of the query. Similarly, if none of the fields in the table have values, I only have a comma in the field on the subreport. My question is how do I eliminate preceding "spaces" or eliminate the comma to leave a blank field in the subreport. I don't want to make the fields required in the data entry form for the table because this information is often not available. I have tried variations of the following in code for the subreport as well as the main report, but I get an error that I can't assign a value to this field:
If Left(me.readdress,2)=" " then
me.readdress=right(me.readdress,(len(readdress)-2))
end if
I know this would only solve my problem of two preceding "spaces", but I figured if this worked, I could work out the rest. I also don't want to eliminate null values for the above fields in the query because I think that would eliminate records in the query (such as a student's name and exam score) that I need to include in the report (subreport). Any suggestions on this? Is it coding I need in the report or something in the query? Thanks in advance!