General discussion

Locked

Access query

By jsteele ·
I am moving some stuff from excel to access. I am having a problem with one equation that I am trying to make a query. I have the following equation in Excel: =DEGREES(ATAN(B12/B11))
How would I write this formula in an access query.

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Access query

by john_wills In reply to Access query

This isn't very pretty. In the query have a calculated column, thus:
trigbit: trigthing([SSN]/[sex])

In a Visual Basic module have a constant and function, thus:

Public Const pi = 3.14159265358979

Public Function TrigThing(number As Long) As Long
TrigThing = 180 / pi * (Atn(number))
End Function

Double or Decimal may be better than long, but basically this works.

Collapse -

Access query

by jsteele In reply to Access query

Poster rated this answer

Collapse -

Access query

by kees.valkenswaard In reply to Access query

What is against using in your query grid the following field?
Result: Atn([b11]/[b12])*180/3,14159265358979
This assuming that the other fields in the table are b11 and b12.
NOTE It may be needed tot use . [dot] and not , [comma] in PI.
Good luck

Collapse -

Access query

by jsteele In reply to Access query

Poster rated this answer

Collapse -

Access query

by jsteele In reply to Access query

Point value changed by question poster.

Collapse -

Access query

by sparky_132 In reply to Access query

an easier way of writing pi is instead of 3.14..... use: pi=atn(1)*4

visual basic is a good way of solving this.

visual basic trig functions must have the angles in radians, so to convert b12 and b11 to radians if they are not in radians is to times the angle in degrees by (pi/180). rad=angle*pi/180

to convert back to degrees from radians: deg=rad*180/pi

create variables b11 and b12 as doubles:
dim b11 as double, b12 as double

atan is inverse tan. so do
atn(b12/b11)

then you must convert this to degrees
atn(b12/b11)*180/pi

so hav a variable to hold this value
dim answer as double
answer= (atn(b12/b11))*180/pi

however as you are using this in a query it would just be:

(atn(b12/b11))*180/pi

!where b12 and b11 must be field names!

that should work

Collapse -

Access query

by sparky_132 In reply to Access query

sorry, i forgot in access pi is not listed as a constant so u must use an integer 3.1415926535897932 etc. depending on the degree of accuracy you want. so it will now be:
--------------------------------
-- (atn(b12/b11))*180/3.14159 --
--------------------------------

(where b12 and b11 are field names)

Collapse -

Access query

by jsteele In reply to Access query

Poster rated this answer

Collapse -

Access query

by jsteele In reply to Access query

This question was closed by the author

Back to Web Development Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums