446,224 Members | 1,143 Online Need help? Post your question and get tips & solutions from a community of 446,224 IT Pros & Developers. It's quick & easy.

# function calling another function

 P: 2 In MS Access i have a function that is calculating the distance between two locations using the latitude and longitudes for two points assuming the earth is flat and the lat and long are perpendicular. I called that function distance. My issue in moving forward is taking the distance i am given from the above function and bringing it into another function i call function wp. I would like to say if the distance is less than 300 then calculate this formula or if it is less than 500 calculate another, less than 1000 another, and so on. I am having issues with my second function calling the distance function and then running certain formulas for each case Any help would be great Dec 11 '07 #1
3 Replies

 Expert Mod 10K+ P: 12,392 Assuming that you can't combine both functions and that you can't call one function from the other, you just need to store the result of the first function using whatever method you want and then pass it to the second function as a parameter. From the sounds of the first function, you seem to know how to pass parameters and have functions return values. So it's not that much harder to just store the result of the first function either temporarily or permanently and then pass it to the second function. So unless I've misunderstood something, it sounds like you should have enough knowledge to do this. Dec 11 '07 #2

 Expert 100+ P: 108 From what I can tell here unless you need to call the distance function for another reason you should be able to combine the two into one function. The best way for this would be to use "SELECT CASE" to determine which formulas to run. The code would be something like: Expand|Select|Wrap|Line Numbers x =    Select Case x     Case                Case             End Case   This should allow you to calculate the distance and store it in "x" then by setting up the criteria in the "Select Case" it should execute the proper code or formula for each distance. Dec 11 '07 #3

 Expert 5K+ P: 8,669 In MS Access i have a function that is calculating the distance between two locations using the latitude and longitudes for two points assuming the earth is flat and the lat and long are perpendicular. I called that function distance. My issue in moving forward is taking the distance i am given from the above function and bringing it into another function i call function wp. I would like to say if the distance is less than 300 then calculate this formula or if it is less than 500 calculate another, less than 1000 another, and so on. I am having issues with my second function calling the distance function and then running certain formulas for each case Any help would be great Unless the logic and coding are more complex than what originally appears, why export the Return Value of Function 1 to Function 2 for a final analysis? Why not keep all the code In-Line? Dec 12 '07 #4 