# Web Development

Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

## General discussion

Locked

### Access query

By ·
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.

Thread display: Collapse - | Expand +

## All Comments

Collapse -

### Access query

by 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 In reply to Access query

Poster rated this answer

Collapse -

### Access query

by 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 In reply to Access query

Poster rated this answer

Collapse -

### Access query

by In reply to Access query

Point value changed by question poster.

Collapse -

### Access query

by 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 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 In reply to Access query

Poster rated this answer

Collapse -

### Access query

by In reply to Access query

This question was closed by the author

## Related Discussions

• 12

tcavadias ·

• 23

tcavadias ·

• 1

DenhamT ·

• 1

#### How to use Nuget assembly as files with visual studio community?

wm.m.thompson ·

• 3

#### How to remove badware from my website?

Sasha Valentina ·