UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Populate Unbound Text Filed In Ms Access Report Via Tempvars Populated From A Dlookup Function, Access 2016    
 
   
djrivers
post Nov 13 2017, 09:54 PM
Post#1



Posts: 3
Joined: 13-November 17



I'll try my very best to explain what I'm trying to bo. I'm still kinda novice in MS ACCESS and still trying to learn stuff. So what I'm trying to do is to populate the control source of an unbound textbox in Report. If for example I use this code
CODE
="<p>my name is <b>" & [fullname] & "</b>.</p>"
, it will work. The
CODE
[fullname]
field will be populated by the value assigned to it. But if I put that same code in a table then use the dlookup function to store the code in tempvars then use the tempvars to populate the unbound textbox, it will not work.

The unbound textbox is set to rich text so it recognizes the
CODE
<b></b>
and makes it bold but the value for the [fullname] field is not populated. It will just be returned as: my name is
CODE
" & [fullname] & "
.

Is there a way to do it so ms access will still populate the [fullname] value and not translate it literally?

Thanks, Darren
Go to the top of the page
 
theDBguy
post Nov 13 2017, 10:02 PM
Post#2


Access Wiki and Forums Moderator
Posts: 71,214
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Welcome to UtterAccess!
welcome2UA.gif

In Access, data is stored in tables. So, when you used "...& [fullname] &...," you were referring to the field [fullname] in the table, and Access produced the data stored in the table. Now, when you store "[fullname]" in the table, then Access will simply retrieve the data you stored in the table, which was "[fullname]." Access has no way of knowing your intention. Assuming the [fullname] field you're trying to store in the table is also availabe withing the same table, you might be able to use a Calculated Field in the table to do the same thing you were doing in the report. So, rather than using a Text field, try using a Calculated field.

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
djrivers
post Nov 13 2017, 10:30 PM
Post#3



Posts: 3
Joined: 13-November 17



Hi,

Thank you for the reply. smile.gif I did some digging here about Access Reports and I found a solution posted by you theDBGuy way back 2010 hehehe. I used the .ControlSource so Me.txtContent.ControlSource = ([TempVars]![FirstResponse]). The tempvar value was passed by the DLookUp function. I did work. It acknowledged both the HTML tags and returned the value of the field ex [fullname] populating the unbound textbox. But it created another problem. There were two other unbound text boxes in the MS Report. It use to display values in them but after what I did. The values won't show anymore. It will show if I remove the code Me.txtContent.ControlSource = ([TempVars]![FirstResponse]) but will disappear once I put it back.

What could be the reason?

Darren
Go to the top of the page
 
theDBguy
post Nov 13 2017, 10:35 PM
Post#4


Access Wiki and Forums Moderator
Posts: 71,214
Joined: 19-June 07
From: SunnySandyEggo


Hi Darren,

Since I cannot see your Report, my guess is the other textboxes were referring to the first one. If so and since you assign a value to it using code, I am thinking the other two textboxes were seeing it as empty when they want to display their values. You can either use code for the other two textboxes just like you did with the first one or try to use the TempVars in the Control Source directly rather than using code. For example, try:

=[TempVars]![TempVarName]

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
djrivers
post Nov 13 2017, 10:42 PM
Post#5



Posts: 3
Joined: 13-November 17



THAT WORKED!!!! thumbup.gif Thank you so much. smile.gif
Go to the top of the page
 
theDBguy
post Nov 13 2017, 10:52 PM
Post#6


Access Wiki and Forums Moderator
Posts: 71,214
Joined: 19-June 07
From: SunnySandyEggo


Hi,

You're welcome! Glad we could assist. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    12th December 2017 - 04:32 PM