The best way to do this ?

Bullet

New member
Local time
Today, 07:12
Joined
Mar 2, 2009
Messages
8
Basically i know how i would do this in excel but does anyone have any idea's in access (seeing as im fairly new to access the most basic way would probly be best)

I've got a button called "Total"

What i need is it do perform the following calulation when selected:

If checkbox 1 is selected 0.99 x perimiter - otherwise 0
If checkbox 2 is selected 3.49 x area required - otherwise 0
If checkbox 3 is selected 3.00 x area required - otherwise 0

If Fitting (another checkbox) is selected 20.00 + 1.49 x area req - Otherwise 0

Would a macro be the way to do this or should i go for VB coding, and either way, would anyone be able to help me to do this ???


Kind Regards
Bullet :)
 
I would suggest you create a function to examine all the parameters and from that evaluate a formula to give you an answer.

In the first instance you need to know what the numerator is:

If ChkBox1 = True then
Numerator = .99
ElseIf ChkBox2 = True Then
Numerator = 3.49
ElseIf ChkBox3 = True then
Numerator = 3
End If

Repeat similar coding to get the other entities that would build up your formula then contruct your formula and aggregate it to a textbox.

David
 
I would use VB programming personally, but some others may prefer macros.

Dim area As Double
Dim perimeter As Double

If Not IsNull(txtArea) Then
area = txtArea
End If

If Not IsNull(txtPerimeter) Then
perimeter = txtPerimeter
End If

If Not area = 0 Or Not perimeter = 0 Then
If checkbox1 = True Then
txtAnswer1 = 0.99 * perimeter
Else
txtAnswer1 = 0
End If

If checkbox2 = True Then
txtAnswer2 = 3.49 * area
Else
txtAnswer2 = 0
End If

If checkbox3 = True Then
txtAnswer3 = 3 * area
Else
txtAnswer3 = 0
End If

If chkfitting = True Then
txtAnswer4 = 20 + (1.49 * area)
Else
txtAnswer4 = 0
End If
Else
MsgBox "Please fill in a value"
End If

Attached is an example of how this code works.

EDIT: Geez you guys got to it just before I made the example. I thought of the numerator idea DCrake, but because he's multiplying it by different things (perimeter in some cases, area in other cases) I didn't know if that would be as adaptable if his equations ever got more complicated in the future.
 

Attachments

Users who are viewing this thread

Back
Top Bottom