VBScript Labels- Multiple field values

325
3
Jump to solution
08-28-2017 09:27 AM
Highlighted
New Contributor

I am currently working on a label in which I am grabbing the data from one field (Element Name), then using data from an equipment field related to phasing. I want to return the data in A phase (Device Equipment A), unless empty, then B unless empty, then C. My vb skills are extremely rusty and I do not remember how to do this for more than two possible outcomes.

Can someone help me with the structure of this statement in order to get the results I seek? Thanks for any time spent helping.

I just drew a blank after the following:

[ElementName] & vbnewline & (...

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Honored Contributor

It would be something like

Function FindLabel ([ElementName], [DEVICEA], [DEVICEB], [DEVICEC] )
  If IsNull( [DEVICEA] ) then
    If IsNull( [DEVICEB] ) then
      Findlabel =  [ElementName] & vbnewline & [DEVICEC]
    Else
      Findlabel =  [ElementName] & vbnewline & [DEVICEB]
    End if
  Else
    FindLabel = [ElementName] & vbnewline & [DEVICEA]
  End if
End Function  ‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

3 Replies
Highlighted
MVP Honored Contributor

It would be something like

Function FindLabel ([ElementName], [DEVICEA], [DEVICEB], [DEVICEC] )
  If IsNull( [DEVICEA] ) then
    If IsNull( [DEVICEB] ) then
      Findlabel =  [ElementName] & vbnewline & [DEVICEC]
    Else
      Findlabel =  [ElementName] & vbnewline & [DEVICEB]
    End if
  Else
    FindLabel = [ElementName] & vbnewline & [DEVICEA]
  End if
End Function  ‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

Highlighted
New Contributor

After tweaking the fields to match the data, this returned my labels as I wanted them perfectly. Thank you for the help!

Reply
0 Kudos
Highlighted
MVP Honored Contributor

Glad to help. Please remember to mark the question as answered.