Skip to main content

Search

Search

Drop Down List Of Addresses

Comments

1 comment

  • Avatar
    Ian Cummings
    Moderator

    Yes a VB script will be needed for the drop down list form control as we don't support a database lookup option directly.  Here is the code that we use to populate a list control in the BarTender prompt form.  Note that there are some items that are likely to change depending on the data file, its structure and what data exactly is wanted for this list.

     

     

     
    Functions and Subs
    dim objConn
    dim strConn
    dim rs
    
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\items and item numbers.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

Please sign in to leave a comment.