Skip to main content

Search

Search

Newbie Questions

Comments

1 comment

  • Avatar
    Domingo Rodriguez
    Moderator

    BarTender doesn't currently support connecting a drop-down list control to a database data source. This is in our feature request list.

     

    1.-    In BarTender there are currently two type of database record selection dialogs, one is called the "query prompt" dialog, where you actually need to directly write the query prompt value (no drop-down list selection), and then you also have the "record selection" dialog, where you get a view of your database (or a view of the query prompt selected records), and you just select which (and in what quantity) records you wish to print.

    Both type of dialogs are explained in the following training video:
    http://www.bartenderbarcodesoftware.com/label-software/training-video-(selecting-records-from-a-database-at-print-time).aspx

    2.-    Find attached as well an example on how to make a query prompt selection by using a Drop-Down list. In order to test this label, copy the Excel spread sheet to the location “C:\Seagull”. First of all we have to populate the dropdown list using the data from a data source. To see this code click “Dropdown List Options”, select “List Items” and then the “Edit VB Script…” button.

     

    You will notice the following code in order to populate the list.

    Functions and Subs

    dim objConn
    dim strConn
    dim rs

    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Seagull\Drop down.xls';Extended Properties=""Excel 8.0;HDR=YES;"""

    Public Function GetNames()
        Dim strNames
         Set objConn = CreateObject("ADODB.Connection")
        objConn.Open strConn
        Set rs = CreateObject("ADODB.Recordset")
        Set rs = objConn.Execute("SELECT * FROM [Sheet1$]")
         strNames = ""
        rs.MoveFirst()
        do while NOT rs.EOF
            strNames = strNames + rs.fields("Fruit") + vbCrLf
            rs.MoveNext()
        loop
        GetNames = strNames
    End Function

    OnFillList

    Value = GetNames()
     

    The next thing that we have to do is to populate our other text objects based upon the data that has been selected in the drop down list via a query. The following code is in the second text object and displays the price, relating to the fruit that has been selected.

     

    This is the code that populates the data for this object:

     

    dim objConn
    dim strConn
    dim rs

    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Seagull\Drop down.xls';Extended Properties=""Excel 8.0;HDR=YES;"""
    Set objConn = CreateObject("ADODB.Connection")
    objConn.Open strConn
    Set rs = CreateObject("ADODB.Recordset")
    Set rs = objConn.Execute("SELECT * FROM [Sheet1$] WHERE Fruit = '" & TextFruit & "'")
    Value = rs.fields("Price")
     

     

    3.-  With regards to the BT sample documents, none of the samples will show you how to perform a Drop-Down list with database source items, but you should find these samples under "C:\Users\$User Name$\Documents\BarTender\BarTender Documents". If they don't appear, then try to reinstall BarTender just in case.

    0

Please sign in to leave a comment.