Zum Hauptinhalt gehen

Suche

Suche

VBScript from 10.0 SR4 to 11.5 - VBScript in Data Entry Form Using Named Substring

Kommentare

3 Kommentare

  • Avatar
    Peter Thane

    I have not had any issues with any VB going between the versions but then I have gone in stages and not in one big jump.

    I am not sure what the problem could be but have you checked the ODBC driver details specified are correct and you could also try reconnecting to the Format.NamedSubStrings("pn").Value value from the column on the right in case something has messed up there?

     

    0
  • Avatar
    Florian Kneissl

    Dear Peter,

    thanks for your assistance!

    I checked the ODBC driver details:

    columnName = "columnname"
    server = "server"
    db = "db"
    userId = "user"
    password = "password"
    dsn = "Driver={MySQL ODBC 9.3 UNICODE Driver};Server=" & server & ";Database=" & db & ";User=" & userId & ";Password=" & password & ";"
    
    'pn = Format.NamedSubStrings("pn").Value
    'Debug:
    pn = "TESTPN"
    
    Set objCon = CreateObject("ADODB.Connection")
    objCon.ConnectionString = dsn
    objCon.Open
    strCon = "SELECT " + columnName + " FROM table WHERE pn = '" + pn + "' AND valid = '1'"
    Set rs = CreateObject("ADODB.Recordset")
    Set rs = objCon.Execute(strCon)
    result = rs(columnName).value
    msgbox (result)

    => I receive a correct database query result for “TESTPN”.

    Same without hardcoded value for pn:

    columnName = "columnname"
    server = "server"
    db = "db"
    userId = "user"
    password = "password"
    dsn = "Driver={MySQL ODBC 9.3 UNICODE Driver};Server=" & server & ";Database=" & db & ";User=" & userId & ";Password=" & password & ";"
    
    pn = Format.NamedSubStrings("pn").Value
    'Debug:
    'pn = "TESTPN"
    
    Set objCon = CreateObject("ADODB.Connection")
    objCon.ConnectionString = dsn
    objCon.Open
    strCon = "SELECT " + columnName + " FROM table WHERE pn = '" + pn + "' AND valid = '1'"
    Set rs = CreateObject("ADODB.Recordset")
    Set rs = objCon.Execute(strCon)
    result = rs(columnName).value
    msgbox (result)

    => Same result: “Either BOF or EOF is True, or the current record has been deleted. The requested operation requires a current record ”

    No result is shown in the Data Entry Form; but the named source itself is correctly filled and printed on the label.

    If I just add a text field with the same named data source in the Data Entry Form, the value is filled out correctly … So I have the following results:

    • using the query prompt to fill a named data source works
    • using the named data source as value for a text input field on the Data Entry Form works
    • using a VBScript in the Data Entry Form for getting a additional database query result with hardcoded value instead of named data source value works
    • using the same script in the Data Entry Form with the named data source value instead of a hardcoded value does not work.

    Using this results, I tried the following:

    Using the Named Data Source in the Data Entry Form as source for a new dropdown-list with the following list element code:

    Source: Visual Basic Scripting; script:

    Value = Format.NamedSubStrings("pn").Value

    Result: The value is only the default text for the Named  Data Source, not the one entered in the query form.

    As a demonstration, I made a new sample label with a sample text database.

    Here is my description:

    So I have a small text database with four values (PN1234, PN2345, PN3456 and PN4567).

    On the label I add both the named data source and the database field 1:

    On the Data Entry Form, I use a dropdown with the named data Source:

    When I print or preview the first time:

    I receive this Data Entry Form:

    The PN from the promt is not used, but the sample text… Choosing the “SampleValueDataSource”, I receive the following label in the “printed” preview:

    I don't know why the named data source value is not updated? The DataBase Field1 is correctly printed.

    If I remove the dropdown on the Data Entry Form (without any further changes):

    and repeat the described procedure:

    I receive - as I would expected in every case - as “printed” preview:

    Same result if I use a “Text Field” instead of a dropdown. But: since it is not possible to fill a Text Field on the Data Entry Form with VBScript, it is no workaround for me:

    Query for PN:

    Data Entry Form after above query with correct “PN” value:

    “Printed” label preview:

    With a dropdown and VBScript filling its values using the named data source, the named data source value is handled from query to form, but not from form to label. Same result (not shown above in pictures) is when I use a “List field” instead of a dropdown, and use VBscript to fill in the Format.NamedSubStrings("pn").Value.

    Both without a dropdown and with a text field (without using VBScript), the named data source value is handled from query to form to label.

    So I assume it is a VBScript issue, when handling named Data Source Values in a Data Entry Form?

    Is there any option to enable a handling of such data sources in the Data Entry Forms? Maybe something that was not neccessary in 10.0 SR4?

    Sorry for the mass of pictures.

    Here is the described sample label on our wetransfer-account for download: https://we.tl/t-VVqDIk14Hh

    0
  • Avatar
    Bart K

    I found this post after searching for an answer to an error I get with Bartender Cloud, Print History, attempting to ‘reprint’ a label:
    The print job failed due to an error.Reprinting job failed. An error occurred after the job was executed. Substring lengths error encountered. Details: 'The sum of the substring lengths '26' is '26'.
     

    Preview of the label is shown without any issues. I haven't yet attempted to print to actual printer so I don't know if it will work or not. 

    I'm not really sure what is causing it, but I suspect it might be overlapping text fields within the label. 

     

    0

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