Change the field content when printing

N

Nicobou

I would like to change the field content before to print the detail part of
my print out.
I have two fields. The first one must be complete with the content of the
second one when printing (or previewing).
Example:

Field1 = "I have a good <Param1> !"
Field2 = "idea"
The result expected is: "I have a good idea!" <Param1> must be replace by
the filed2 content.

Many thanks in advance.

NB
 
M

Marshall Barton

Nicobou said:
I would like to change the field content before to print the detail part of
my print out.
I have two fields. The first one must be complete with the content of the
second one when printing (or previewing).
Example:

Field1 = "I have a good <Param1> !"
Field2 = "idea"
The result expected is: "I have a good idea!" <Param1> must be replace by
the filed2 content.

=Replace(field1, "<Param1>", Field2)
 
N

Nicobou

Sorry but I don't find the function Replace() in the expression builder.
Where do I have to look for?
 
N

Nicobou

Thanks a lot.
I wrote a VB function to call the function Replace().
But I have still a problem when the original string doesn't content the
searched substring I have an error generated and can't trap it before the
printing.
I was looking for a substring search function ... ? I am not a VB expert :)
Any idea?

Nicolas
 
M

Marshall Barton

Nicobou said:
I wrote a VB function to call the function Replace().
But I have still a problem when the original string doesn't content the
searched substring I have an error generated and can't trap it before the
printing.
I was looking for a substring search function ... ? I am not a VB expert :)


What version of Access are you using?

Can't tell what's wrong with your code unless I can see the
code. Please post a Copy/Paste of your procedure.
 
N

Nicobou

It is working now. The error was that the replace() function doesn't accept
an empty field (null or blank value) in the pRelacement string and I had some
"null or blank" values in the <Param1> field.
I replaced the null value in my table field with a not null string and then
that worked.
Do you have another idea to fix this problem.
NB
 
M

Marshall Barton

Nicobou said:
It is working now. The error was that the replace() function doesn't accept
an empty field (null or blank value) in the pRelacement string and I had some
"null or blank" values in the <Param1> field.
I replaced the null value in my table field with a not null string and then
that worked.
Do you have another idea to fix this problem.


If you want to replace a substring with nothing, then the
replacement string needs to be a string with no characters.
This is known as a ZLS (Zero Length String) and, in VBA, is
written as "".

You can get a ZLS in a table without user intervention by
setting the field's properties to:

Allow Zero Length Yes
Required Yes
Default Value ""
 
N

Nicobou

Thanks a lot for your help. Nic.

Marshall Barton said:
If you want to replace a substring with nothing, then the
replacement string needs to be a string with no characters.
This is known as a ZLS (Zero Length String) and, in VBA, is
written as "".

You can get a ZLS in a table without user intervention by
setting the field's properties to:

Allow Zero Length Yes
Required Yes
Default Value ""
 
Top