Zum Hauptinhalt gehen

Suche

Suche

Changing Text Color From Database

Kommentare

7 Kommentare

  • Avatar
    Fernando Ramos Miracle

    Hello Billo4th,

     

    Could you please clarify what exact value you've stored on your database?

     

    Note that "btRed" is not a value that will be accepted by the "TextColor" property. Actualkly if you want it red it will accept "Red" directly, or "BtColor.Red".

     

    Please consult BarTender's Help to find a full list of accepted colors (run a search for "BtColor object").

     

    Regards.

    0
  • Avatar
    Legacy Poster

    Fernando,

     

    Sorry for my typo, the values in my database are BtColor.Red, BtColor.Blue, etc. It just seems that I can't use the data field directly

     

    Format.Objects("Text 1").TextColor =  Field("BILL.Color")

     

    or read it into a variable and then use the variable

     

    mColor = Field("BILL.Color")

    Format.Objects("Text 1").TextColor = mColor

     

    Bill

    0
  • Avatar
    Fernando Ramos Miracle

    Hello Bill,

     

    Could you let me know exactly when are you getting this error message?

     

    Please note that when working on the "OnNewRecord" event and with database fields in your script, the database data won't be loaded until you actually send a print job. Being that the case, when you use  field references you will usually get an error message when closing the script assistant, not because the code is wrong, but because the database field is empty or the default data is not "compatible" with what you are doing with it.

     

    Do test doing a print preview or directly sending a print job with your previous code, and let me know if that generated an error too.

     

    Regards.

    0
  • Avatar
    Legacy Poster

    If I use either of my prior examples I do not get an error when I test the code, and no error saving it. The error ONLY happens with

    a print preview or direct print. The exact error message window is:

     

    BarTender: Error Message #3904

    The following script error occurred:

    OnNewRecord(line 12): : Type mismatch: 'Format.Objects(...).TextColor

    0
  • Avatar
    Michael Toupin (mtoupin

    Where are you putting the VB script?  To be able to manipulate the color of an object you need to be doing it in the BarTender Document options, not on a label object itself. 

     

    Go to File>BarTender Document Options, then the VB Scripting tab, your script should be here, not in an object on the label itself.

    0
  • Avatar
    Legacy Poster

    That is where I have my script.

    0
  • Avatar
    Legacy Poster

    Go to File>BarTender Document Options>VB Scripting tab>OnNewRecord>Edit..

     

    ReferenceField("Sheet1$.Color")

    dim mColor

    mColor = Field("Color")

    If (mColor = "BtColor.Orange") Then

        Format.Objects("Text 1").TextColor = BtColor.Orange

    End If

    If (mColor = "BtColor.Red") Then

       Format.Objects("Text 1").TextColor = BtColor.Red

    End If

    If (mColor = "BtColor.Blue") Then

       Format.Objects("Text 1").TextColor = BtColor.Blue

    End If

    If (mColor = "BtColor.Black") Then

       Format.Objects("Text 1").TextColor = BtColor.Black

    End If

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.