Display Text Based On Database Field
-
I was able to get this to work by adding the code directly to the data source you want to change (in your example: "What I Want to change"). Then just yield the result by assigning it to "Value".
I don't know why your approach doesn't work though. I think it might be a similar issue I had in the past (I made a topic here called "Update NamedDataSource Through OnIdenticalCopies" - am unable to link it here because somehow the link functionality doesn't work in my browser or something...).
0 -
Awesome it worked Thank you i was banging my head for over an hour yesterday. :)
0 -
I have a similar problem and have been looking through the forum for a solution without luck. I am very new to VB Scripting but I don't think what I am trying to do is all that complicated. I just can't get it to work.
I have a text object on my label that I am trying display certain texts depending on the value of a database field. Example:
if isnull(Field("USER_DEF3")) then
Value = "EXP DATE"
Else
Value = "SHELF LIFE DATE"
end ifI've tried this in the Transforms tab VB Script in both the Functions and Subs, and the OnProcessData. The only result I get is "SHELF LIFE DATE" even if the field is NULL so I don't think the data is being read correctly. This data is pulled from a SQL 2012 database and the field is definitely NULL or NOT NULL. No blank spaces.
Any suggestions would be so appreciated.
0 -
I'm not sure you can count on VBS understanding the content of that field as "Null" the same way your database does. Is there a reason not to use the following?
If Field("USER_DEF3") = "" Then ...You can also test what VBS actually "sees" in the field using the VarType function, e.g. like this:
MsgBox(VarType(Field("USER_DEF3")))You can interpret the outcome here: https://msdn.microsoft.com/en-us/library/3kfz157h(v=vs.84).aspx
0 -
Thank you KM3. I knew the solution had to be simple. That worked.
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
5 Kommentare