Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get value from a table for calculation in forms

Status
Not open for further replies.

tintin007

Technical User
Aug 11, 2000
8
0
0
CA
I have a table with two fields (ID,TAX1,TAX2) where I store my TAX1 & TAX2 value preceded by the ID of the country where they applicated for calculation in forms.&nbsp;&nbsp;The user have to select the country and the TAX values comes in automaticaly.&nbsp;&nbsp;So I don't know how to capture these data and put them in my formula to calculate the total price of my invoices.<br><br>I'm a bit newbie with VB variables and modules so be precise in your answer please.<br><br>
 
I think you are looking for the DLookup function. Check it out in Access Help - it gives examples there.
 
Hi tintin007,<br><br>yep dlookup() will do this,<br><br>i assume that the user will select the country with a combo box or what ever call this SelectCountry<br><br>maybe <br>&lt;global in module&gt;<br>dim TaxRate as variant 'needs to handle &quot;null&quot;<br><br>in the SelectCountry_AfterUpdate event do <br>dim tempID as integer<br><br>tempID = me.SelectCountry<br>' get the TaxRate could extend this with select case<br>if me.SelectCountry = onevalue then<br>&nbsp;&nbsp;&nbsp;TaxRate = Dlookup(&quot;[TAX1]&quot;,&quot;TableName&quot;,&quot;ID = &quot; & tempID)<br>else<br>&nbsp;&nbsp;&nbsp;TaxRate = Dlookup(&quot;[TAX2]&quot;,&quot;TableName&quot;,&quot;ID = &quot; & tempID)<br>end if<br>' do calculation<br>if isnull(TaxRate) then<br>&nbsp;&nbsp;&nbsp;' the lookup operation failed!<br>else<br>&nbsp;&nbsp;&nbsp;'do calculations etc<br>&nbsp;&nbsp;&nbsp;'TaxRate has the required value based on country!<br>end if<br><br>see ta<br>RobertD<br><br>
 
Hi tintin007<br><br>I have used the DLookup function very often and it's a truly powerful function. <br><br>There is yet another solution...<br><br>Since the user has to select the country id from the tax table anyway, why not have a form(pop-up or otherwise) from which the user can select the country id. In that case, assuming the form is called frmTaxTable, all you have to do after the user selects the country id from a combo box bound to the ID table, is to use Forms!frmTaxTable!Tax1 or ....Tax2<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top