Prob???????

K

KRISH

Hi Everybody

I have created a Table1 with field [Para1]. Now I am
storing a value in [Para1] like,

"Thank you, " & [First Name] & " for your donation"

[First Name] is the field of another tabel say [Customer].

In the report I am placing a unbound text box and set its
control source to say [Para1]. Now my problem is if I open
the report it is showing the value of unbound text box as
below:

"Thank you, " & [First Name] & " for your donation"

But actually I want [First Name] should be replaced by the
name of the customer.

kindly help how to solve it. Thanks for any help.

krish
 
A

Allen Browne

Krish, to do that you would need to use an unbound text box. Then in the
Format event of the section that contains this text box, lookup the values
in the table, and assign the result to the Control Source of your text box,
with an Equal sign at the start.

Something like this:

Private Sub Detail_Format(...
Dim varResult as String
varResult = DLookup("Para1", "Table1")
If IsNull(varResult) Then
Me.MyTextbox.ControlSource = vbnullstring
Else
Me.MyTextbbox.ControlSource = "=" & varResult
End If
End Sub

My guess is that it would be more efficient to place a token in the para1
field, and use Replace() rather than reassign the text box for each record.
 
K

KRISH

Thanks for your reply.
You are suggesting to leave token in para1 and use replace
() rather than reassign the text box for each record. I
could not understand the logic. I would be greateful if
you give one example. Thanks.

krish
-----Original Message-----
Krish, to do that you would need to use an unbound text box. Then in the
Format event of the section that contains this text box, lookup the values
in the table, and assign the result to the Control Source of your text box,
with an Equal sign at the start.

Something like this:

Private Sub Detail_Format(...
Dim varResult as String
varResult = DLookup("Para1", "Table1")
If IsNull(varResult) Then
Me.MyTextbox.ControlSource = vbnullstring
Else
Me.MyTextbbox.ControlSource = "=" & varResult
End If
End Sub

My guess is that it would be more efficient to place a token in the para1
field, and use Replace() rather than reassign the text box for each record.


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.
Hi Everybody

I have created a Table1 with field [Para1]. Now I am
storing a value in [Para1] like,

"Thank you, " & [First Name] & " for your donation"

[First Name] is the field of another tabel say [Customer].

In the report I am placing a unbound text box and set its
control source to say [Para1]. Now my problem is if I open
the report it is showing the value of unbound text box as
below:

"Thank you, " & [First Name] & " for your donation"

But actually I want [First Name] should be replaced by the
name of the customer.

kindly help how to solve it. Thanks for any help.

krish


.
 
A

Allen Browne

Thought I did give you an example. Here is is again:

<quote>
In Access 2000 and later, you can use the Replace() function to replace the
text in the memo field with the value from the field.

For example, if your memo field contains:
Thank you, <firstname>, for your donation
then on your report, you would use a text box with ControlSource of:
=Replace([MyMemo], "<firstname>", [First Name])

Make sure the Name of this text box is not the same as the name of a field:
that causes an error in Access.

If you have lots of these replacements to make, it is probably easiest to
write a function that opens the table of replacements and loops through all
those records to perform each replacement, returning the resultant string.
</quote>

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

KRISH said:
Thanks for your reply.
You are suggesting to leave token in para1 and use replace
() rather than reassign the text box for each record. I
could not understand the logic. I would be greateful if
you give one example. Thanks.

krish
-----Original Message-----
Krish, to do that you would need to use an unbound text box. Then in the
Format event of the section that contains this text box, lookup the values
in the table, and assign the result to the Control Source of your text box,
with an Equal sign at the start.

Something like this:

Private Sub Detail_Format(...
Dim varResult as String
varResult = DLookup("Para1", "Table1")
If IsNull(varResult) Then
Me.MyTextbox.ControlSource = vbnullstring
Else
Me.MyTextbbox.ControlSource = "=" & varResult
End If
End Sub

My guess is that it would be more efficient to place a token in the para1
field, and use Replace() rather than reassign the text box for each record.


Hi Everybody

I have created a Table1 with field [Para1]. Now I am
storing a value in [Para1] like,

"Thank you, " & [First Name] & " for your donation"

[First Name] is the field of another tabel say [Customer].

In the report I am placing a unbound text box and set its
control source to say [Para1]. Now my problem is if I open
the report it is showing the value of unbound text box as
below:

"Thank you, " & [First Name] & " for your donation"

But actually I want [First Name] should be replaced by the
name of the customer.

kindly help how to solve it. Thanks for any help.

krish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top