Pythagoras Calc on Form

  • Thread starter Thread starter Andy Roberts
  • Start date Start date
A

Andy Roberts

What I need to do to have a form where someone can input 2 co-ordinates
(i.e. x and y of each point). In another unbound box it needs to calculate
the distance between the two points. I have no problem setting this up and
I know the equation, but I can't figure out how to build that equation in
access.

The equation is

square root of (x2-x1)squared + (y2-y1)squared.

The formula is better explained here
http://www.mathwarehouse.com/algebra/distance_formula/interactive-distance-formula.php

Regards

Andy
 
Andy said:
What I need to do to have a form where someone can input 2
co-ordinates (i.e. x and y of each point). In another unbound box it
needs to calculate the distance between the two points. I have no
problem setting this up and I know the equation, but I can't figure
out how to build that equation in access.

The equation is

square root of (x2-x1)squared + (y2-y1)squared.

The formula is better explained here
http://www.mathwarehouse.com/algebra/distance_formula/interactive-distance-formula.php

There is a square root function Sqr(number) and you can use X^2 to square a
value. So...

Sqr((x2-x1)^2 + (y2-y1)^2)
 
Thanks Rick

It was the squaring a value I didn't know. However, it still isnt working.

What I have in the control sourceof the textbox is

=Sqr([tblSections!EndEasting]-[tblSections!StartEasting])^2+([tblSections!EndNorthing]-[tblSections!StartNorthing])^2

It looks fine to me?

Andy
 
Andy said:
Thanks Rick

It was the squaring a value I didn't know. However, it still isnt
working.
What I have in the control sourceof the textbox is

=Sqr([tblSections!EndEasting]-[tblSections!StartEasting])^2+([tblSections!EndNorthing]-[tblSections!StartNorthing])^2

It looks fine to me?

Sorry, but without refreshing myself on the specifics of your calculation I'm
not sure where your parenthesis should be. I'm assuming you want the square
root of the entire rest of the expression like...

square root of ( (x2-x1)squared + (y2-y1)squared )

If, so you have your parenthesis wrong because you have...

square root of ( (x2-x1) )squared + (y2-y1)squared

....which must be wrong because you are taking the square root of the same value
you are squaring so they cancel out.
 
Andy Roberts said:
Thanks Rick

It was the squaring a value I didn't know. However, it still isnt
working.

What I have in the control sourceof the textbox is
=Sqr( ([tblSections!EndEasting]-[tblSections!StartEasting]) ^ 2 +
([tblSections!EndNorthing]-[tblSections!StartNorthing]) ^ 2)
It looks fine to me?

You're missing some parentheses. See above

Tom Lake
 
Thanks for your patience Rick

I have had another look at it and I've amended it to

=Sqr(([txtEndEasting]-[txtStartEasting])^2+([txtEndNorthing]-[txtStartNorthing])^2)

which works fine, except for the number of decimal places. I want it to 2
decimal places and I think I need to use the ROUND function. Where would
that sit in the overal syntax

Andy



Rick Brandt said:
Andy said:
Thanks Rick

It was the squaring a value I didn't know. However, it still isnt
working.
What I have in the control sourceof the textbox is

=Sqr([tblSections!EndEasting]-[tblSections!StartEasting])^2+([tblSections!EndNorthing]-[tblSections!StartNorthing])^2

It looks fine to me?

Sorry, but without refreshing myself on the specifics of your calculation
I'm not sure where your parenthesis should be. I'm assuming you want the
square root of the entire rest of the expression like...

square root of ( (x2-x1)squared + (y2-y1)squared )

If, so you have your parenthesis wrong because you have...

square root of ( (x2-x1) )squared + (y2-y1)squared

...which must be wrong because you are taking the square root of the same
value you are squaring so they cancel out.
 
Andy Roberts said:
Thanks for your patience Rick

I have had another look at it and I've amended it to

=Sqr(([txtEndEasting]-[txtStartEasting])^2+([txtEndNorthing]-[txtStartNorthing])^2)

which works fine, except for the number of decimal places. I want it to 2
decimal places and I think I need to use the ROUND function. Where would
that sit in the overal syntax

=FormatNumber(Sqr(([txtEndEasting]-[txtStartEasting])^2+([txtEndNorthing]-[txtStartNorthing])^2),
2)

Tom Lake
 
Thanks Tom

Job Done

Andy

Tom Lake said:
Andy Roberts said:
Thanks for your patience Rick

I have had another look at it and I've amended it to

=Sqr(([txtEndEasting]-[txtStartEasting])^2+([txtEndNorthing]-[txtStartNorthing])^2)

which works fine, except for the number of decimal places. I want it to
2 decimal places and I think I need to use the ROUND function. Where
would that sit in the overal syntax

=FormatNumber(Sqr(([txtEndEasting]-[txtStartEasting])^2+([txtEndNorthing]-[txtStartNorthing])^2),
2)

Tom Lake
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top