weight * price = amount S’abonner

0
Avatar
Mario Brunet

Good morning . I need to make the product of two variables (weight * price = amount). The weight is taken from a field in a database (txt file) and the amount is entered using a form or by modifying a text on the label. The result I need to print it. I have tried to carry this result in a text with data source as command visula basic but I have not succeeded. I hope your help thanks.

5 commentaires

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

Hi Mario,

I believe you need to make the VB field performing the calculation an Event Controlled VB script routine using the Post Prompt option. 

1. Name the field that's data is entered on the form as will make the next bit easier, using the Data Source>Change Data Source Name button

2. As above set the result field as an Event Controlled VB Script field and also set the Data Type tab option to Currency before clicking the Edit with Script Editor button.

3. Once in the Script Editor, scroll down and choose the Post Prompt option and in the new box on the right type 

Value1 = 

and then on the column left double click on the database field that contains the weight.

4. Press enter to move to a new line and type

 Value2 = 

and then again from the column on the left double click on the name given to the manual entry field per 1. above from the Named Data Sources list

5. Again press Enter and then on a 3rd line add the code

Value = Value1 * Value2

 

Click Close twice and that should be it  

Pete

 

0
Avatar
Mario Brunet
Actions pour les commentaires Permalien

Hi, Pete.

I have not achieved the expected result. I do not get the VB commands to treat the text as a numerical value or currency.

Thank you very much
0
Avatar
Pete Thane
Actions pour les commentaires Permalien

You do not to be in the VB editor to change the data type to a currency value that can be set in the basic settings of the data source itself. 

If you come out of the VB editor and return to the Text Properties of the field itself and with the data source highlighted you should have three tabs you can select from on the right hand side. Choose the middle one of the these (Data Type) and use the dropdown to adjust it the setting to  Currency.

(There is a way in VB to convert a field to a currency value but the above option is far simpler)

Pete

0
Avatar
Mario Brunet
Actions pour les commentaires Permalien

Hello Peter

I have this confuration well.

My problem is that I can not multiply the weight I take from a database and the value of a text box in a form.

 


Greetings.

0
Avatar
Pete Thane
Actions pour les commentaires Permalien

The sum will not appear on the data entry form but will when the label is previewed or printed. This is the code I have used under the Event Controlled Scripts > OnPostPrompt option

Value =Format.NamedSubStrings("pricedb").Value * Format.NamedSubStrings("weightmanual").Value

where pricedb is the name I gave to the field on the label that displays the price from the database and weightmanual is the name I gave to the label field that is linked to the Data Entry Form box where the operator enters the weight.

I also set the VB script field's Data Type to Currency and so the displays in UK pounds for me as that is my default currency setting for my computer.  

Vous devez vous connecter pour laisser un commentaire.