Insert variable in memo field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My form displays a memo field. The users review long statements to determine
whether or not to use the statement on a report. And as part of the statement
i would like to have inserted in the middle several fields such as job#,
date, seller. These have already been populated in the form.
How can i do this?
 
Hi,



If the to be inserted expression are, say, easily recognizable, use replace.

As example, if the memo string is:

str= "Dear [clientName], In relation with our contract number
[ContractNumber], please... "

then

str=Replace( str, "[ClientName]", [ClientName] )
str=Replace( str, "[ContractNumber]". [ContractNumber] )

Me.ControlName.Value = str


You place the code in the appropriate event (onFormat, probably) of the
appropriate detail (of your report).


Hoping it may help,
Vanderghast, Access MVP
 
Michel,

Thanks for your reply...
2 questions:
1. Is "str" the name of the memo field?
2. Is your "Dear [clientName]...example the syntax that i should see when
viewing my memo field on the form?


Michel Walsh said:
Hi,



If the to be inserted expression are, say, easily recognizable, use replace.

As example, if the memo string is:

str= "Dear [clientName], In relation with our contract number
[ContractNumber], please... "

then

str=Replace( str, "[ClientName]", [ClientName] )
str=Replace( str, "[ContractNumber]". [ContractNumber] )

Me.ControlName.Value = str


You place the code in the appropriate event (onFormat, probably) of the
appropriate detail (of your report).


Hoping it may help,
Vanderghast, Access MVP


Zachry1 said:
My form displays a memo field. The users review long statements to
determine
whether or not to use the statement on a report. And as part of the
statement
i would like to have inserted in the middle several fields such as job#,
date, seller. These have already been populated in the form.
How can i do this?
 
Hi,


That was intended to be some VBA code. str would be a VBA variable:


Dim str as string


and we will start the process by putting into it, the content of the memo
field:

str= Me.ControlNameWIthTheMemo


We would not let the memo, itself, visible. Instead, a standard text control
would receive the content of str, once all Replace would have been executed:


Me.TextBoxControl = str



The "Dear {ClientName} ... " was intended to be an example of what is the
memo BEFORE any substitution. It is the job of the Replace to substitute
any recognizable expression, here I use {ClientName} , by whatever you want.
This is NOT a mandatory syntax. You just choose YOUR convention, and write
the appropriate Replace:


str=Replace( str, "{ClientName}", FieldForTheClientName )




Hoping it may help,
Vanderghast, Access MVP


Zachry1 said:
Michel,

Thanks for your reply...
2 questions:
1. Is "str" the name of the memo field?
2. Is your "Dear [clientName]...example the syntax that i should see when
viewing my memo field on the form?


Michel Walsh said:
Hi,



If the to be inserted expression are, say, easily recognizable, use
replace.

As example, if the memo string is:

str= "Dear [clientName], In relation with our contract number
[ContractNumber], please... "

then

str=Replace( str, "[ClientName]", [ClientName] )
str=Replace( str, "[ContractNumber]". [ContractNumber] )

Me.ControlName.Value = str


You place the code in the appropriate event (onFormat, probably) of the
appropriate detail (of your report).


Hoping it may help,
Vanderghast, Access MVP


Zachry1 said:
My form displays a memo field. The users review long statements to
determine
whether or not to use the statement on a report. And as part of the
statement
i would like to have inserted in the middle several fields such as
job#,
date, seller. These have already been populated in the form.
How can i do this?
 
Thanks Michel

Michel Walsh said:
Hi,


That was intended to be some VBA code. str would be a VBA variable:


Dim str as string


and we will start the process by putting into it, the content of the memo
field:

str= Me.ControlNameWIthTheMemo


We would not let the memo, itself, visible. Instead, a standard text control
would receive the content of str, once all Replace would have been executed:


Me.TextBoxControl = str



The "Dear {ClientName} ... " was intended to be an example of what is the
memo BEFORE any substitution. It is the job of the Replace to substitute
any recognizable expression, here I use {ClientName} , by whatever you want.
This is NOT a mandatory syntax. You just choose YOUR convention, and write
the appropriate Replace:


str=Replace( str, "{ClientName}", FieldForTheClientName )




Hoping it may help,
Vanderghast, Access MVP


Zachry1 said:
Michel,

Thanks for your reply...
2 questions:
1. Is "str" the name of the memo field?
2. Is your "Dear [clientName]...example the syntax that i should see when
viewing my memo field on the form?


Michel Walsh said:
Hi,



If the to be inserted expression are, say, easily recognizable, use
replace.

As example, if the memo string is:

str= "Dear [clientName], In relation with our contract number
[ContractNumber], please... "

then

str=Replace( str, "[ClientName]", [ClientName] )
str=Replace( str, "[ContractNumber]". [ContractNumber] )

Me.ControlName.Value = str


You place the code in the appropriate event (onFormat, probably) of the
appropriate detail (of your report).


Hoping it may help,
Vanderghast, Access MVP


My form displays a memo field. The users review long statements to
determine
whether or not to use the statement on a report. And as part of the
statement
i would like to have inserted in the middle several fields such as
job#,
date, seller. These have already been populated in the form.
How can i do this?
 
Back
Top