auto update ratio calculation

potts

Registered User.
Local time
Today, 00:09
Joined
Jul 24, 2002
Messages
87
It's been a while since I built an access application and so this could be relatively simple - might just need the cobwebs cleared out of the old noggin!

I have a table that contains two variables (var1 and var2) and the ratio of one to the other i.e.

ratio = var1 / var2

Now I know I can build a query to calculate one of the three variables (ratio, var1, var2) provided I select two of them for the user to enter - simple enough calculation.

However, what I would really like to do is make the whole thing a bit more fluid by permitting the user to enter any two of the three variables and have the third one calculated. So my questions are these:

1. What do I write to build the function
2. Where do I attach the function

Any help would be greatly appreciated

Thanks
 
Lets see if this can clear some of them

Dunk this into a module:

Public Function Ratio(Optional Var1 As Integer, _
Optional var2 As Integer, _
Optional Ratio As Double) As String
If IsNull(Var1) Then
'calc var1
ElseIf IsNull(var2) Then
'calc var2
ElseIf IsNull(Ratio) Then
'calc Ratio
Else
'nothing to calc
End If
End Function

Put in some calculations and presto!

Regards
 
Thanks for the reply, but at the risk of sounding ridiculously stupid, where do I attach the module - the form itself, control box, or not to anything?

Like I say - cobwebs!!!
 
In the modules part of the db...

Then you can call the function from anywhere ... a query or form or control... anything....anywhere anytime

Regards
 
Sorry, perhaps I should have been more clear. I knew to build it in the modules section, and that I could call it from a form or query, or control. It's the how to call it that I'm having hassle with, both in a form and query. It would be great if you could show me how.

Thanks
 

Users who are viewing this thread

Back
Top Bottom