跳到主内容

搜索

搜索

Drop Down Menu And Vb Script

评论

16 条评论

  • Avatar
    Ian Cummings
    版主

    I really struggle to understand what you want here for both of your explanations.

     

    Do you want a drop down list of items as part of a data entry form?  (yes/no)

     

    If yes, is the list of items fixed or from a file/database of some sort?

     

    Perhaps you want the drop down list to affect other form controls in the data entry form dynamically?  Such that if you select the colour "Blue" in the drop down, you then get a list of items to choose that relate to that blue product?  Is this the sort of thing you are after?

     

    Perhaps the drop down list is the input for the BarTender document's database query, instead of the usual text input box?

    0
  • Avatar
    Legacy Poster

    Hi I'm a newbie and have a very similar request in that I am using BarTender 10 and want to create a drop down list that will pull a listing of about 20 different product names from an excel file that's located on a network drive. Can this be done and how?

    0
  • Avatar
    Ian Cummings
    版主

    daron_d:  Here is an example script for data sourcing the content of a list form control from a network folder.  Of course you just need to modify it for your own particular needs.  Note that the connection string will change depending on the file version of the Excel file.  A quick Google search should uncover a connection string for the file version you need.

     

     
    Functions and Subs
     
    dim objConn
    dim strConn
    dim rs
     
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\ServerName\SharedFolder\Products.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("Item") + vbCrLf
            rs.MoveNext()
        loop
        GetNames = strNames
    End Function
     
     
    OnFillList
     
    Value = GetNames()
    0
  • Avatar
    Legacy Poster

    Hi Admin, i tried using your script but I keep getting a script error with the drop down list.

     

    I need to get this function working on a product label for our plant, and I just can't seem to get this working. Seagull Scientifics telephone tech support doesn't seem to fully support configuring drop downlist menus in BarTender. So is there someone whom you can suggest that can do this maybe as a paid service?

    0
  • Avatar
    Ian Cummings
    版主

    What's the error message exactly with your script?  I trust you changed the path/filename of the Excel file in the connection string?  Have you tried the reseller from whom you purchased BarTender?

    0
  • Avatar
    Legacy Poster

    I'm going to try the string again and just try a local path on my pc. I would normally contact Seagull Scientifics tech support for assistance and the reseller I don't think has the technical resource to help with this question. It may take me a couple of days but I'll report back to you. Thanks for your help thus far.

    0
  • Avatar
    Legacy Poster

    I have a label for a product that has 20 different part numbers. I created a drop down menu so you can choose the part number to print. It prints the number and also a barcode below it. 

     

     

    How did you do this? I need to link a drop down menu to a text field and a barcode so when a product is selected from the drop down menu the name and corresponding barcode will appear on the label. The drop down menu itself will be pulling information from a text file or excel spreadsheet.

     

    Anything helps!

    0
  • Avatar
    Domingo Rodriguez
    版主

    The example I've attached will first show items from your database in a drop-down list. The code for it is as follows:

     

    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()
     

     

    Once you select a value from the drop-down list, you may want other objects on the BT document to now show the content from a different field, but for the same record you've chosen in the drop-down list. In order to do so, you would need to do a query prompt on the database:

     

    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")
     

    0
  • Avatar
    Legacy Poster

    Domingo,

     

    I'm getting an error using the above code when the field in the database is a number. Can you please help.

     

    OnFillList(Line 2):: Type mismatch: 'Value'

     

    Thanks,

    Buddy

    0
  • Avatar
    Legacy Poster

    I believe I understand gfaz1069's request as I am looking for a similar task. I am trying to replace another software title with BarTender. I have an Access database that needs to be used. The person printing the label, needs to do the following:

    1- open Print Station and choose label

    2- use a dropdown list to select OUR part number

    ** - OUR partnumber will print on the label as TEXT, it will cross ref (using the db) to the CUSTOMER part number which will populate a TEXT field and a BARCODE. In addition, there are several other TEXT fields that will populate all because we selected OUR part number.

    I have been trying to make this work for hours and am getting no where. I have tried the help file and user manual, but no luck.

    0
  • Avatar
    Domingo Rodriguez
    版主

    Buddy,

     

    Can you perhaps attach your database and modified .btw document to examine? Do this using the "More Reply Options" button.

    0
  • Avatar
    Legacy Poster

    Hi Ian,

    With reference to your earlier reply:

     

    "Perhaps you want the drop down list to affect other form controls in the data entry form dynamically?  Such that if you select the colour "Blue" in the drop down, you then get a list of items to choose that relate to that blue product?  Is this the sort of thing you are after?"

     

    This is exactly what I'm after, is this possible? Is there an example?

    Cheers.

     

    0
  • Avatar
    Ian Cummings
    版主

    jon2263: Unfortunately this is not possible as currently the data entry form doesn't support any kind of OnChangeData in a form control event.  Your only option is to develop a separate front-end application, using something like VB.NEt, to act as the data entry form for the user, and then for it to control a BarTender process via automation in order to print a label.  The below white paper will get you started in this respect.

     

    http://www.seagullscientific.com/label-software/whitepapers/controlling-barcode-label-software-using-c-sharp-and-vb.net(english).pdf

    0
  • Avatar
    Legacy Poster

    Hello,

    I am currently trying to set up some templates for a client and wanted to incorporate some dropdown lists that link to a database.

     

    This VB script in this post was helpful but the VB script in the post applies the one field to both the 'Display Text' and the 'Data Source Value'. I would like to modify it so that the dropdown list "Display Text' reads from one field and the 'Data Source Value' reads from another field from the same excel spreadsheet. 

     

    Any help would be appreciated.

     

    We are resellers of Bartender software and TSC printers.

    0
  • Avatar
    Michael Toupin (mtoupin
    Basically you'd have to modify the script to put 2 fields in there: do while NOT rs.EOF strNames = strNames + rs.fields("Fruit") + vbCr + rs.fields("NotFruit") + vbCrLf rs.MoveNext() You want it to concatenate the two fields with a vbCR in the middle, and add the CRLF just at the end for each line.
    0
  • Avatar
    Legacy Poster

    Mike T,

    Thank you for the reply. I have tried to modify the code as you instructed but it just reads <script error> under the display text and data source value.

     

    Forgive me, I am not a programmer. I pasted the modified VB script below. Maybe you can see what I did wrong.

    Do you have to change anything in the OnFillList?

    Would it help to send the spreadsheet and BT document?

    I basically want the IDENTIFIER to show up in the drop down list during data entry but the corresponding SHIP TO ADDRESS to be printed on the label.

     

    dim objConn
    dim strConn
    dim rs
     
    strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='S:\Barcode Doctor\Sievert\AMAZON FC DB.xlsx';Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1;"""
     
     
    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("IDENTIFIER") + vbCr + rs.fields("SHIP TO ADDRESS") + vbCrLf
            rs.MoveNext()
        loop
     
        GetNames = strNames
     
    End Function
    0

请先登录再写评论。