basic question about updating page

  • Thread starter Thread starter Ciaran
  • Start date Start date
C

Ciaran

Hi I'm new to access and I can't for the life of me figure out how to call a
VB function that calculates and keeps all info on my form up to date. I want
to invoke the function when any data on the form changes. None of the form
events seem to work?!
Cheers,
Ciarán
 
it's hard to give specific suggestions from such vague information, but in
general i can tell you that: data isn't stored in a form; it's stored in a
table and displayed via a form. if you change data in a control in a form,
you can run code from the control's AfterUpdate event. if you're calculating
values and storing the results in a field in the form's underlying table,
probably you shouldn't be - as long as you're storing the raw data, you can
use it in calculations whenever and wherever you need it.

hth
 
tina said:
it's hard to give specific suggestions from such vague information, but in
general i can tell you that: data isn't stored in a form; it's stored in
a
table and displayed via a form. if you change data in a control in a form,
you can run code from the control's AfterUpdate event. if you're
calculating
values and storing the results in a field in the form's underlying table,
probably you shouldn't be - as long as you're storing the raw data, you
can
use it in calculations whenever and wherever you need it.

hth



Thanks for the reply - It helped a little. I don't think I was particularly
vague tho. I just want to know:
What event is triggered when any data on a form changes?
or
Is there an onKeyPress event that works for the entire form and not just one
field?

Regards my calculations: I am calculating totals that are too complicated
for the expression builder. I am not storing them in the table. I need to
include if statements in the calculations and I dont think it can handle
them can it?

Specific Example:
totalbox.Value = costbox.Value * quantbox.Value
If monthly.Value Then totalbox.Value = totalbox.Value * monthspan
End If

Is something like this possible using the control source of a text box?

Thanks,
Ciarán
 
What event is triggered when any data on a form changes?

None that I know of.
or
Is there an onKeyPress event that works for the entire form and not just one
field?

Yes; set the KeyPreview property of the form to Yes.
Regards my calculations: I am calculating totals that are too complicated
for the expression builder. I am not storing them in the table. I need to
include if statements in the calculations and I dont think it can handle
them can it?

It certainly can. You're limited to several hundred characters of expression
which can call builtin or custom functions.
Specific Example:
totalbox.Value = costbox.Value * quantbox.Value
If monthly.Value Then totalbox.Value = totalbox.Value * monthspan
End If

Is something like this possible using the control source of a text box?

Yes. You don't need the .Value property for one thing, it's the default. This
expression could be written

=[Costbox] * [Quantbox] * (IIF([Monthly], [monthspan], 1)


John W. Vinson [MVP]
 
The KeyPress event is not appropriate for detecting changes in data! It
triggers when any key is hit, including when the <Tab> or <Enter> keys are
used for navigation! The Form_Dirty is more along the line of what the OP
needs, I think, assuming this is a bound form. It triggers when a single
character is added/changed.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
John W. Vinson said:
What event is triggered when any data on a form changes?

None that I know of.
or
Is there an onKeyPress event that works for the entire form and not just
one
field?

Yes; set the KeyPreview property of the form to Yes.
Regards my calculations: I am calculating totals that are too complicated
for the expression builder. I am not storing them in the table. I need to
include if statements in the calculations and I dont think it can handle
them can it?

It certainly can. You're limited to several hundred characters of
expression
which can call builtin or custom functions.
Specific Example:
totalbox.Value = costbox.Value * quantbox.Value
If monthly.Value Then totalbox.Value = totalbox.Value * monthspan
End If

Is something like this possible using the control source of a text box?

Yes. You don't need the .Value property for one thing, it's the default.
This
expression could be written

=[Costbox] * [Quantbox] * (IIF([Monthly], [monthspan], 1)

Thanks for the help John - I'm familiar with java based languages like
javascript & actionscript so this Access stuff seems quite foreign to me! It
makes sense now that I see it. I appreciate your time.
Ciarán
 

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