change record values after checkbox "YES"

DonLduk

New member
Local time
Today, 09:57
Joined
Oct 2, 2008
Messages
8
Hello all.

Im currently building a DB with Access and Ive found myself coding simple VB lines (its been about 6 years since Ive programmed! im doing allright though.) in order to make it work as I want to, but I ran into a problem and im kind of stuck.

I have a Calls table with about 5 fields, one of them being "TARIFF VALUES".

Also I have a Details table which I have among the fields "Taxes in Tariffs" checkbox as well as a "Tax Value" textbox.

So, what I do is put the "Calls" table as a subform of the "Details", and what I need to have is that when I click the checkbox "taxes in tariffs" in the "details" table, the "tariffs value" field in the subform updates to the same value multiplied by the tax value
(tariff value * (1+ tax value in %))

and also if I uncheck it deduces the Tax value

I figured i'd put the code in the AfterUpdate event of the checkbox, but I just dont know how to tell it to access the subform field Tariff Value for take it and modify it in the

If taxChk.value=true then
Calls.???? = Calls.???? * (1 + details.???)


Can anybody guide me through? i'd really apreciate the help. thanks in advance!
 
here is a hint , you reach a control inside a subform by typeing its path , ex :
Code:
Forms![yourmainformname]![yoursubformname]![yourcontrolname].value   'VBA Version
Or
Code:
Me.yourmainformname.yoursubformname.yourcontrolname.value   'VB Version
now assigning values you acquire from these control to varriables , ex:
Code:
Dim lngTax As Long
lngTax = Forms![yourmainformname]![yoursubformname]![yourcontrolname].value
running whatever math on which , ex:
Code:
lngResult = lngTax * 1.2 * lngTarrif  ' Blas Blas
then assigning results back to whichever control you chose should be all to it , ex:
Code:
Forms![yourmainformname]![yoursubformname]![yourcontrolname] = lngResult
now where you trigger all that is up to you (Click event on a checkbox , button , picture button , losefocus , you name it)
 
Hello.

1st of all thanks for your reply.

Your explanation worked a lot and helped me to access controls. But I have one question.

I need to apply the "math" to a whole column of data- the tariff column. How do I tell it to run through that column and change every value of it?

thanks again.
 

Users who are viewing this thread

Back
Top Bottom