By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,121 Members | 1,706 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,121 IT Pros & Developers. It's quick & easy.

function with variables from different forms

P: n/a
I wrote a simple funtion to automatically compute corrected azimuths
in several places in a database but am having trouble implementing it.
I placed the function in a module and am trying to pass to it three
variables: magnetic declination, compass degrees and declination
direction (east or west). The idea is that a user will enter the
current magnetic declination and direction in a form and have those
parameters apply to other forms (where the unique ids match).

How do I pass the variables to the function in the module and have the
function result passed back to the correct text box on the form?

I tried calling the function simply by placing
"=f_compute_true_magnetic([frm_sample_event].[current_mag_dec_direction],[Me].[azimuth_magnetic],[frm_sample_event].[current_mag_declination])"

in the form load event line in the properties of my form. I also
placed this line in the After Update event for object
(azimuth_magnetic) I'm trying to update on form. And it's not
working. The "frm_sample_event" is where the mag dec and direction
are entered.

I also tried putting the function in the code for the form and
entering:
azimuth_corrected = f_compute_true_magnetic([frm_sample_event].[current_mag_dec_direction],
[Me].[azimuth_magnetic], [frm_sample_event].[current_mag_declination])

in the Form Load event but I get an error when I try to open that form
from the frm_sample_event.

Thanks for any help you can offer.

Doug in Alaska
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Databases are about stored data, and you didn't give us much information
about how you've stored your data. Nor did you indicate how you wanted to
invoke the function -- whether from code, or as the ControlSource of a
Control or ???.

Let's assume the former:

In the Click event of a Command Button on the form where the arguments are
in Controls named, txtMD, txtCD, and txtDD, call your Azi function as
follows:

CorrAz = Azi(Me!txtMD,Me!txtCD,Me!txtDD)

If in Control Source, then we'll assume your form is frmF, the Control
Source would be:

= Azi(Forms!frmF!txtMD,Forms!frmF!txtCD,Forms!frmF!t xtDD)

The "apply to other forms" would mean that you'd make sure the record was
saved using Me.Dirty = False, and then Requery the other forms -- if they
are all bound.

I trust you aren't planning on storing redundant data that you could as
easily calculate when you need to use or display it.

Larry Linson
Microsoft Access MVP

"Wilder" <Do*********@nps.gov> wrote in message
news:b2*************************@posting.google.co m...
I wrote a simple funtion to automatically compute corrected azimuths
in several places in a database but am having trouble implementing it.
I placed the function in a module and am trying to pass to it three
variables: magnetic declination, compass degrees and declination
direction (east or west). The idea is that a user will enter the
current magnetic declination and direction in a form and have those
parameters apply to other forms (where the unique ids match).

How do I pass the variables to the function in the module and have the
function result passed back to the correct text box on the form?

I tried calling the function simply by placing
"=f_compute_true_magnetic([frm_sample_event].[current_mag_dec_direction],[Me
].[azimuth_magnetic],[frm_sample_event].[current_mag_declination])"
in the form load event line in the properties of my form. I also
placed this line in the After Update event for object
(azimuth_magnetic) I'm trying to update on form. And it's not
working. The "frm_sample_event" is where the mag dec and direction
are entered.

I also tried putting the function in the code for the form and
entering:
azimuth_corrected = f_compute_true_magnetic([frm_sample_event].[current_mag_dec_direction], [Me].[azimuth_magnetic], [frm_sample_event].[current_mag_declination])

in the Form Load event but I get an error when I try to open that form
from the frm_sample_event.

Thanks for any help you can offer.

Doug in Alaska

Nov 12 '05 #2

P: n/a

"Wilder" <Do*********@nps.gov> wrote in message
news:b2*************************@posting.google.co m...
I wrote a simple funtion to automatically compute corrected azimuths
in several places in a database but am having trouble implementing it.
I placed the function in a module and am trying to pass to it three
variables: magnetic declination, compass degrees and declination
direction (east or west). The idea is that a user will enter the
current magnetic declination and direction in a form and have those
parameters apply to other forms (where the unique ids match).

How do I pass the variables to the function in the module and have the
function result passed back to the correct text box on the form?

I tried calling the function simply by placing
"=f_compute_true_magnetic([frm_sample_event].[current_mag_dec_direction],[Me
].[azimuth_magnetic],[frm_sample_event].[current_mag_declination])"
in the form load event line in the properties of my form. I also
placed this line in the After Update event for object
(azimuth_magnetic) I'm trying to update on form. And it's not
working. The "frm_sample_event" is where the mag dec and direction
are entered.

I also tried putting the function in the code for the form and
entering:
azimuth_corrected = f_compute_true_magnetic([frm_sample_event].[current_mag_dec_direction], [Me].[azimuth_magnetic], [frm_sample_event].[current_mag_declination])

in the Form Load event but I get an error when I try to open that form
from the frm_sample_event.

Thanks for any help you can offer.

Doug in Alaska

Visit the official MVP site:
http://www.mvp.org
Kelly Rees-Danforth, MVP
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.