Calculating Values

  • Thread starter Thread starter GB
  • Start date Start date
G

GB

I use a form to enter the order detail information for my Quotation dB. On
this form I can enter the order detail info, qty, size, colour, etc.

On the main form I have a subform displayed in 'Datasheet' view that lists
all the order items that have already been entered.

Problems:

1). Upon entering the info for each line the subform does not display the
'items'. The only way I can get the Subform to display the info is by
clicking in the subform and sorting it. This seems to then load the data.

2). I need to 'calculate' the price for each item by running a series of
queries, I do this by having a 'Calculate Price' button which runs the
queries (a macro). Clicking the button always runs the queries but unless
the info is displayed in the subform no calculation is performed.

It is almost as though my data is not populated until I click out of the
main form and into the subform.

Any help much appreciated, I expect you'll have noticed I'm a little new to
this!

Cheers,
 
Problems:

1). Upon entering the info for each line
the subform does not display the 'items'.
The only way I can get the Subform to
display the info is by clicking in the sub-
form and sorting it. This seems to then
load the data.

This is to be expected. The subform can only display information that has
been saved and the information you enter into a record on the main form is
not saved until (1) you move off the record (2) explicitly save it (3) move
from the main form into a subform or (4) close the form.

So you will have to determine at what point you believe the data in the main
form is "ready to save" and put in code to save it explicitly and then
Requery the Subform Control. A Command Button would be one way -- usually
that is "overkill" because of the automatic saves described earlier -- it
could contain:

DoCmd.RunCommand acCmdSaveRecord
Me.<yoursubformcontrolsname>.Requery

You could also put the second of these statements in the AfterUpdate event
of the Main Form if your Subform doesn't appropriately update when you move
to the next record on the main form.
2). I need to 'calculate' the price for each
item by running a series of queries, I do this
by having a 'Calculate Price' button which
runs the queries (a macro). Clicking the button
always runs the queries but unless the info
is displayed in the subform no calculation is
performed.

I don't quite understand what you mean here. Unless a Query refers to
Controls on a Form, it would not be affected by whether the data involved
were or were not displayed. Perhaps this, too, is a place where you need to
Requery the Subform Control after you do the update.
It is almost as though my data is not
populated until I click out of the
main form and into the subform.

BINGO! You guessed it (though there are a few other ways to make sure the
data is updated, as described).

Larry Linson
Microsoft Access MVP
 
Are you saying the data you enter into the main form is copied down to the
subform. Why the duplication?
 
Back
Top