Skip to main content



Can I Use Two Databases Independently Without Joining?



  • Avatar
    Ian Cummings

    Unfortunately, currently we only support related tables/databases in the main database connection configuration for a BarTender document.


    However, it sounds like you just need to configure a database look-up for this item.  This can be achieve through the use of a VB script for the source of the form field instead of embedded data.  Here is an example of the code you would use to populate a list control in the BarTender data entry form from an Excel file.


    *Note that you'll need to change folder/file/sheet/field names for your own purposes.


    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 = ""
        do while NOT rs.EOF
            strNames = strNames + rs.fields("Item") + vbCrLf
        GetNames = strNames
    End Function
    Value = GetNames()
  • Avatar
    Legacy Poster

    I am in a similar situation, but retrieving records from a SQL Server database using a System DSN.    The query is working correctly when i run it directly against the database, so there must be an issue somewhere else.  Any ideas what the issue is?



    'Connect to the system DSN
    Value = Value

    Dim conn
    Set conn = CreateObject("ADODB.Connection") "IMFTest905", "Corp\svc_epicor", "Norgren01"

    'get the view with usercode values that we need
    Dim strSQL
    strSQL = "select Number01 from v_labelcodes where v_labelcodes.CodeTypeID = 'ARTPAM' AND v_labelcodes.CodeID = 'F'"
    Dim rs
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open strSQL, conn


    'make sure we have one record, and if so, set the value to Number01
    if rs.RecordCount = 1 then
     Value = rs("Number01")
     Value = Value
    end if


    'close the connection, clean up
    set conn = Nothing


Please sign in to leave a comment.