Hi to all!
I’m trying to calculate the taxcode with navision.
I’m almost done , but i have a little problem:
I have to take a value (code) from a field in a variable type record and use this value to calculate taxcode.
I’ll explain:
I have a table “comune” that has three field: IDRECORD,IDPROV, CODE and DESCRIPTION.
This table is related with another table , so I can filter some fields .
In the form I have:
textbox provincia where I select IDPROV
textbox comune where I select a DESCRIPTION related to IDPROV
the tax code has to take field CODE from table “comune” when comune is selected, and put this value, in a variable type text , so it can be calculated.
I tried with function GET, but it doesn’t work.
How can I do that?
If I understand your requirement correctly…
you select IDPROV from Comune table
You select DESCRIPTION from Comune table
Code value from Comune table has to copied to a text variable…
If so,
write below code in Onvalidate field of Description field
Comune.RESET;
Comune.SETRANGE(IDPROV,provincia);
Comune.SETRANGE(DESCRIPTION,comune);
IF Comune.FINDFIRST THEN
Textvariable := Comune.Code;
BTW, what is your primary key in Comune table?
I Select IDPROVINCIA from another table called Provincia.
Then I select Comune from table Comune , comune field is filtered with a table relation,
example:
table provincia
idprovincia descriptionprovincia
AB text1
CD text 4
EF text6
Table comune:
IDPROV descriptioncomune code
AB text1 C123
AB text2 C456
CD text3 D123
CD tex4 D456
When in the form i select AB from table provincia, in textbox comune I see only descriptioncomune that have IDPROV = idprovincia
Now, I don’t have to choose code from table comune through a lookup table, but I need to get that field and put it in the variable Textvariable.
So, I have to use FINDFIRST function?
Is there any chance of
Table comune:
IDPROV descriptioncomune code
AB text1 C123
AB text1 C456
if yes, which value you want?
If you use Findfirst, it will give you C123.
Is there any chance of
Table comune:
IDPROV descriptioncomune code
AB text1 C123
AB text2 C456
if yes, which value you want?
If you use Findfirst, it will give you C123.
I would have value “code” near the field selected.
E.g.
if I select text2, I wolud have code C456.
what is the problem with this code/
Comune.RESET;
Comune.SETRANGE(IDPROV,provincia);
Comune.SETRANGE(DESCRIPTION,comune);
IF Comune.FINDFIRST THEN
Textvariable := Comune.Code;
Maybe I exposed my problem in a wrong way.
So, I’ll explain:
I have a form, who’s source table is the codicefiscale table.
This form has to calculate a tax code, so , if I insert Name, Surname, Date of Birth, BirthPlace I’ll obtain, with an algorithm, the taxcode.
When I choose the birthplace, i choose first the province from the provincetable, and then the town, from the town table (comune).
this two elements are related each other trough a table relation in codicefiscale table (the source table of the form )
When I choos the town, in the table town I have fields descripted above.
Then, when I press Calculate button, I have to catch the value in the field “code” of the town table (who’s name’s “comune”) that I have selected.
With the code that you suggested, nothing happens.
I have not understood where, why and how implement this.
Thank you
Luciana
If I understand Correctly…
In Comune Table, IDPROV is birthplace and DESCRIPTION is town.
If Yes, Write the code onPush Trigger of Calculate.
Comune.RESET;
Comune.SETRANGE(IDPROV,birthplace);
Comune.SETRANGE(DESCRIPTION,town);
IF Comune.FINDFIRST THEN
TaxCode := Comune.Code;
Message(’%1’,TaxCode);