Fred,
Thanks for the advice.
I opened the query used by the report. In design view, I entered the
following text on the criteria row of the AccountNum field in the query grid:
Right([AccountNum],3)
When I ran the query I got an error message regarding the same field name in
2 tables in the query. I then entered this data:
Right([Month End Data.AccountNum],3)
No records returned
In the query there are two tables with the AccountNum field. It is a text
field with a field size of 20 that contains a 11-character account number
(comprised of numbers, not text) I only want to show the last 3 digits of
the account number.
Should the field size be changed? I did not design this database, I am only
making modifications to it.
Thanks,
The Teach
fredg said:
I have a subreport control that generates an account number. I only want to
display the last three characters on the report. I tried using the Right
function in the query but it does not work.
Can you help me with this? Can it be solved in the query or does it require
VBA coding?
Please advise
Just a helpful tip to help you get good responses when asking
questions in newsgroups.
Words like 'That didn't work' gives any potential reader who might
want to help you absolutely no useful information.
What didn't happen?
What did happen?
What did you expect to happen?
Where did you place the code?
What is the exact code you wrote (copied directly from your database
and pasted here so we can see if you didn't simply mis-write the
code)?
Answers to those questions would be helpful to us .... to help you!
As you haven't given the exact expression you used in the query, all I
can say is
NewColumn:Right([FieldName],3)
should return, in that query, the last 3 characters in a field.
If that query is the recordsource for the sub-report, use that query's
[NewColumn] field in the subreport and it should display the last 3
characters.
I believe you are confused.
I certainly am.
Your original message stated you wish to show just the last 3
characters in the field.
I only want to display the last three characters on the report.<
That has NOTHING to do with criteria.
Criteria restricts the records shown, not parts of a field.
Also, if you have more than one table or query do you have a
relationship established between the 2 tables/queries.
If the AccountNum is something like 25815512369 and you just wish to
show the last 3 characters (369) then......
Open the query in design view.
In a NEW COLUMN write, on the Field row (exactly as I have below):
LastThree:Right([Month End Data].[AccountNum],3)
Note the column name LastThree followed by a colon, and also the
separate brackets around both the table and the field names.
Make sure the Show check box is checked.
Do not enter anything else in this column.
Run the query. In addition to all the other fields in the query you
should have a column, named [LastThree], displaying the last 3
characters of the [AccountNum] field.
Use this [LastThree] field in your report (not the AccountNum field) ,
where you wish to display the 3 numbers.
Now if you meant something else in your original message, please
repost with more information.