How to use value from drop down list as a value in another objects script S’abonner

0
Avatar
Joe Knight

 I have done a lot of VBA scripting in the past and have a general understanding of how things should work, but I am having a hell of a time getting even 1 label created in Bartender.  I was given this project after not having coded anything in years and I have muddled a few things together but have run into a problem I have been unable to overcome.  

I am designing a label with a couple data entry fields on it.  The first field is a drop down list which pulls its values from a old access database.  This works, and I can select the field, and the selection appears on the label at print preview.  The second field is a quantity field.  This is where I am stuck.  I have a script put together on this field that will pull the quantity based on the "selection" value however my selection value is static (selection = "PM1001-1").  It works and pulls the quantity for that part and displays it on the label.  However I cannot for the LIFE of me figure out how to have selection equal to the drop down list selected value!

I have tried several things:

selection=Format.Objects("DropListPart").Value - script error-Operation not supported for this object type

I also tried to set the chosen value to a named data source but don't know how to use them really.  What I did was in the drop down list script I put in the line
Format.NamedSubStrings("DropDownList").Value = value    (value is the variable which populates the list)

I then went into the script for the quantity box and added

selection=Format.NamedSubStrings("DropDownList").Value

and I got the error Either BOF or EOF is true.  The current record has been deleted.  Requested operation requires a current record

Any help would be greatly appreciated.  This feels like it should be super simply and I'm just missing the proper syntax to load the value of the dropdown into the variable in the other script.

8 commentaires

0
Avatar
Joe Knight
Actions pour les commentaires Permalien

So I have progressed 1 step further in learning.  I can now make it display on the label itself.  I linked the part number label to the named datasource, which is the linked data source for the drop down.  That made it so when I picked a value in the drop down that became the new named datasource, then I used selection=Format.NamedSubStrings("DropDownList").Value in the script on the quantity field on the label and it shows the quantity based on what I pick

Perfect, except I need the quantity to ALSO update on the drop down list as I am selecting.  It needs to be able to be manually adjusted if the quantity is different for this specific job.

I have a quantity box on the Data Entry Form but it remains empty no matter what I pick, until I click OK and go to the actual label at which time it is populated from the script.  The script currently resides in the OnNewRecord subroutine.  If I move it to the AutoSelectedEvent, then it populates instantly but only with the default first item in the drop down.  It doesn't change after each selection, nor does it change when I go to the label.

Any help out there?

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Hi Joe,

I think it is all a time a thing when the "events" are actioned. Autoselected is when the label is opened so not what you want I dont think and I think the OnNewRecord is prior to the Data Entry/Prompting screens. The OnNewRecord is more connected with Database connections rather than dropdown list situations (ie via the Database Connection Setup for database sourced fields).

Pete

 

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Hi Joe,

I just had a chance to do some testing and I am not sure you can do what you want but if you email me through a copy of your label format I can have a look and and see if there is an alternative route. My email address is info (at) dcatonline.co.uk

Pete 

0
Avatar
Shotaro Ito
Actions pour les commentaires Permalien

BarTender's data entry form cannot refer to currently entered value on the form.

Similar issue discussed in here with an alternative - you can get 2 fields in once, duplicate the text by Object Value, then remove first half / bottom half.
https://support.seagullscientific.com/hc/en-us/community/posts/216550387-List-Box-Selection-To-Populate-Multiple-Substrings-Values-From-Excel-File

0
Avatar
Joe Knight
Actions pour les commentaires Permalien

I figured out how to do what I was trying to do.  I had a simple input form with a drop down list pulling its list items from a parts database.  I picked a part.  The second field was a manual (optional) quantity field.  If data was entered I wanted that quantity printed on the label, if it was left blank then I wanted the quantity pulled from the database based on the part number.  The 3rd field was just a lot number manual entry linked to a label.

I linked the drop down list to a named data source so that whatever value I choose would end up on the label which referenced the named data source as its source.  Then in the quantity label, initially it was just pulling the quantity from the database based on the part number.  What I ended up doing was creating a second named data source and linking that to the quantity input field on the form.  I then edited the input label on the label and added in a quantity variable and threw in an if then statement that said if the quantity named data source was 0 (default - meaning the input form was left blank), then pull from the DB, threw in an else statement at the end that said value=quantity (from the named data source), and it works perfectly.

If I don't enter a quantity the named datasource remains a value of 0 and the script pulls it from the database, if I enter something it's not 0 and the "else" fires and uses whatever value the named data source now has from the input on the form

~dim statements

selection=Format.NamedSubStrings("DropDownList").Value
quantity=Format.NamedSubStrings("QuantityField").Value

If quantity = 0 then

original script pulls quantity from db

else

value = quantity

end if

0
Avatar
Aziz Adilov
Actions pour les commentaires Permalien

Hello Joe Knight,

 

I'm new to Bartender. I saw your solution and it seems like it might work for me.

I'm trying to create a label/form with two related objects. In object 1 user inputs products sku and object 2 is populated with product description for the sku in object 1, pulled from excel database( my first though was to use Vlookup function, which I tried in VB Script, but I got an error, I'm not very good at that). I need to do similar thing for two more objects, but it should be the same process as for object 1 and 2.

I think I understand what you did with your process, just don't know how. There is so much information on bartender online, I can't organize it to figure out how to do what I need to do.

If you could point me to topics describing the steps you took or if you have an idea on how should I approach my process.

 

Thank you,

 

Aziz.

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Hi Aziz,

It sounds like for your solution all you need to do is link the label to your spreadsheet as a database connection and then create a filter for the SKU input field, linking all the appropriate label fields to the matching columns in the spreadsheet.

That would be far simpler than trying to use VB to do this for you.

Pete

0
Avatar
Aziz Adilov
Actions pour les commentaires Permalien

Thank you very much for your suggestion, Pete!

I'll give it a try.

Regards,

Aziz.

 

Vous devez vous connecter pour laisser un commentaire.