Drop Down Menu And Vb Script 关注

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. Some numbers have the same quantity that gets shipped and some have a different number that gets shipped, but the quantity to be shipped is derived from the part number chosen. So I want to display the number to be shipped in another field (location) on the label after I choose my part number. I have been trying to use VB and an IF, Then statement so when a certain part number is chosen, a certain quantity is displayed.

 

This is hard for me to explain because I am very new to the software and I'm trying to take out as much human error as possible.

 

Maybe I can explain it better....when I go to print I get prompted with a drop down menu to choose a part number....I choose....it display the part number and a barcode in another field. I want a quantity display in another field based on the part number. Part numbers 0001 - 0005 have a quantity of 20, part numbers 0006-0020 have a quantity of 30. So when I choose 0001, a 20 will be displayed in another field as well as the part number.

 

Can anyone help me with the Visual basic code or in a different way. I've used the "If" statement in Excel plenty of times, but not sure how it worls in Bartender.

16 评论

0
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

请先登录再写评论。