Validate a form field based on a different field's dropdown list S’abonner

0
Avatar
Graham JENKINS

Using Bartender 2016 R9.

In my form, the user should either select from the Subcontractor dropdown list populated by a database or enter their badge number.

The following logic works on the OnNewRecord event (the model is designed to print multiple copies of a single label), but shows an unfriendly dialog box.

     if Format.NamedSubStrings("Badge").Value="" and Format.NamedSubStrings("Subcontractor").Value="" then
        Format.CancelPrinting("Either the subcontractor or your badge number must be specified")
    end if

If I put this in the OnProcessData event of Badge, the value of SubContractor is empty, even when a value has been selected, and it shows a friendly dialog box.

Is there a way to get the selection from the dropdown list during field validation ?

5 commentaires

0
Avatar
Graham JENKINS
Actions pour les commentaires Permalien

With a little more research, I created a Visual Basic Script named data source of type Event Script, which makes it possible to define an OnPostPrompt event.

This works, but the dialog box does not allow updating of form data, so it's not ideal.

1
Avatar
Pete Thane
Actions pour les commentaires Permalien

Unfortunately there is a not a "between data entry" type VB event (I wish there was) and so the VB has to be processed wither before the data entry or after it. 

The only way I can think of doing this would be to use an Action button:

  • Right click on the Form 1 and rename it (I called mine EntryForm)
  • Use the Add Form button to add a 2nd form to your label. 
  • add an appropriate message to the form 
  • Right click on the Tab of the new form (is the Form 2 above)
  • Click on the Form 2 name in the column on the left and then on the right hand side change the Show When settings by clicking on the ringed button
  • Adjust the Conditionally Based on Expression options to something similar to the below akthough these would be the Badge and Subcontractor in your instance - I had used different names for my quick test
  • Once done click Ok and then on the previous screen click on the word Form on the left and then the Actions button
  • In the Validate Data option highlight the Continue Printing and press the red X to delete it. Now click on the blue + next to Validate Data to add a new option
  • When it opens click on the Forms and Show Forms option and in the box on the right type in the Form name you set for Form 1 above.
  • Click Ok, Close and Template1 to return to your label view and now test your label. What should happen if nothing is selected the new form will appear and then the operator will be returned to the previous screen.

I hope this helps

 

Pete

 

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Sorry meant to add this screen image too

 

0
Avatar
Graham JENKINS
Actions pour les commentaires Permalien

Pete,

That's a good idea. Thanks for your help.

It's a shame that so few VB events are exposed.

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

I agree I do think a OnNewDataForm or similar option would be useful but with the new Actions stuff you can get round some bits.

Just a thought on the new form it maybe better if you remove the existing buttons (right click on the form and on from the Form Properties button untick "include standard buttons") and instead of adding the Actions command to show the first form there, close that screen and from the Data Entry Control dropdown add a Button. In the Properties for that use the Actions add the command to show the other form. Probably a neater solution than leaving a print button showing.

 

Vous devez vous connecter pour laisser un commentaire.