Skip to main content

Search

Search

Accessing Database Fields From Vbscript

Comments

1 comment

  • Avatar
    Fernando Ramos Miracle

    Hello Ron,

     

    *Could you attach a simple label with what you are trying to do, it might be easier to guide you in the right direction.

     

    1. Regarding the capture of the data, please note that if you are retrieving the information from a text file, it will be considered as text. As such, a comparison like "If Value = 2 Then..." won't work because you are comparing a string with an integer type value.

     

    Being that the case your code should work by writing the following:

     

    Dim shelf

     

    shelf = Right(Field("LOCS.Field 1"),1)

    If shelf = "1" Then

          Value = 88

    End if

     

    The main difference between your code and the one above is that I've added quotes to the [1] value in the "If...Then" statement. regarding the rest I've only removed the variables that I think might be redundant.

     

    Also please note that the message you get, is because you are not using the actual value of the data source, and you can of course choose to ignore it (it's a warning, not an error).

     

    2. Although setting the value of the data source to "" could certainly do the trick your second option seems much more interesting. To get that precise symbol you'll need to figure out to which ASCII character they correspond (when using the Symbols font). As a test I've used double arrows, the upper one is 223 and the lower one is 224 ASCII code. This way your code would look as follows:

     

    Dim shelf

     

    shelf = Right(Field("LOCS.Field 1"),1)

     

    If shelf = "1" Then

      Value = Chr(223)

    Else

      Value = Chr(224)

    End If

     

    The Chr() command will get you the ASCII value of the code you enter. Note that the above example will only work on a text object using the Symbols font.

     

    Regards

    0

Please sign in to leave a comment.