473,387 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Datasheet view Subform Totals

First a quick background on the form:

I have a form that is normally viewed in Single form mode. It has a
subform on it that is in datasheet view. The main form is for work
orders and the subform is for parts used on the work order. On the main
form I have a LaborTotal (from main form), PartsTotal (from subform)
and TotalCost (which is Labor + Parts). All works fine as is.

Now to the question:
I have a button on my main form to browse the work orders, which
basically opens up a copy of the same form but datasheet view, so you
can see all the work orders.

In the PartsTotal and TotalCost sections is #Error until you click the
little "+" sign at the left of the row to open the subform, then it
totals properly, even if you close the subform.

Is there any way to correct this? Without having to open this up and
having to click a couple thousand plus signs?

Any help would be appreciated.

Thanks,
Ken Mylar

Mar 16 '06 #1
7 6224
When in data sheet view, the subform isn't activated until you click the +
signs, as you've noted. I have played with this a little in the past and I
think that what I came up with was to turn off screen echo, open the
subform, close the subform, then turn screen echo on again. As you noted,
once the subform has been opened, it still works, even if you close it
again.

Example:
DoCmd.OpenForm "FormName"
Application.Echo False
Forms!FormName.SubdatasheetExpanded = True
DoEvents
Forms!FormName.SubdatasheetExpanded = False
Application.Echo True

--
Wayne Morgan
MS Access MVP
"Ken Mylar" <km****@elch.org> wrote in message
news:11*********************@j52g2000cwj.googlegro ups.com...
First a quick background on the form:

I have a form that is normally viewed in Single form mode. It has a
subform on it that is in datasheet view. The main form is for work
orders and the subform is for parts used on the work order. On the main
form I have a LaborTotal (from main form), PartsTotal (from subform)
and TotalCost (which is Labor + Parts). All works fine as is.

Now to the question:
I have a button on my main form to browse the work orders, which
basically opens up a copy of the same form but datasheet view, so you
can see all the work orders.

In the PartsTotal and TotalCost sections is #Error until you click the
little "+" sign at the left of the row to open the subform, then it
totals properly, even if you close the subform.

Is there any way to correct this? Without having to open this up and
having to click a couple thousand plus signs?

Any help would be appreciated.

Thanks,
Ken Mylar

Mar 16 '06 #2
This took away the #Error in both the Parts and the Totals columns.
However it leaves the Parts blank and gives the Total with only the
Labor, even though there is a part in the subform.

For example:
Results before were:
$120 #Error# #Error
Then when I clicked the "+" to open then close the subform, I got:
$120 $58 $178
Now with the new code for the same record I get:
$120 $120

Maybe it's the way I reference it:
PartsCost =[subfrmWODetailsExtended].[Form]![OrderSubtotal]
TotalCost =nz([Labor Cost])+nz([Parts Cost])

But it works if I manually open and close it.

Thanks for your help,
Ken Mylar

Mar 16 '06 #3
This now sounds like a timing issue. Try changing the TotalCost to:

=Nz([subfrmWODetailsExtended].[Form]![OrderSubtotal]) + Nz([Labor Cost])

Also, before the DoEvents command, try a Me.Recalc command. This alone may
solve the problem, without the change above.

--
Wayne Morgan
MS Access MVP
"Ken Mylar" <km****@elch.org> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
This took away the #Error in both the Parts and the Totals columns.
However it leaves the Parts blank and gives the Total with only the
Labor, even though there is a part in the subform.

For example:
Results before were:
$120 #Error# #Error
Then when I clicked the "+" to open then close the subform, I got:
$120 $58 $178
Now with the new code for the same record I get:
$120 $120

Maybe it's the way I reference it:
PartsCost =[subfrmWODetailsExtended].[Form]![OrderSubtotal]
TotalCost =nz([Labor Cost])+nz([Parts Cost])

But it works if I manually open and close it.

Thanks for your help,
Ken Mylar

Mar 16 '06 #4
Neither one of those worked either.

Here is the code that I had on this browse button before putting any
new code:

************************************************** ************************************************** ***
Private Sub cmdBrowse_Click()

DoCmd.OpenForm "frmWorkOrdersBrowse", acFormDS, , , , acHidden

If IsLoaded("frmWorkOrdersBrowse") Then
Dim F As Form
Set F = Forms!frmWorkOrdersBrowse
F.RecordSource = Me.RecordSource
F.Filter = Me.Filter
F.FilterOn = True
F.OrderBy = Me.OrderBy
F.OrderByOn = True
F.Visible = True
Set F = Nothing
DoCmd.FindRecord Me![WorkOrder#]
End If

End Sub
************************************************** ***********************************
I've tried to just have the code expand the subforms and leave them all
open, just open and close the subforms, and a bunch of variations of
what you gave me and it always locks out the parts.

Thanks,
Ken

Mar 16 '06 #5
The only other thing I can think of would be to force a ReCalc of the
subform then a ReCalc of the main form.

DoCmd.OpenForm "frmWorkOrdersBrowse"
Application.Echo False
Forms!frmWorkOrdersBrowse.SubdatasheetExpanded = True
DoEvents
Forms!frmWorkOrdersBrowse.subfrmWODetailsExtended. Form.Recalc
DoEvents
Forms!frmWorkOrdersBrowse.Recalc
DoEvents
Forms!frmWorkOrdersBrowse.SubdatasheetExpanded = False
Application.Echo True

I said "Me.Recalc" in the last message. The Recalc should actually be for
the main form you're opening.

--
Wayne Morgan
MS Access MVP
"Ken Mylar" <km****@elch.org> wrote in message
news:11********************@i39g2000cwa.googlegrou ps.com...
Neither one of those worked either.

Here is the code that I had on this browse button before putting any
new code:

************************************************** ************************************************** ***
Private Sub cmdBrowse_Click()

DoCmd.OpenForm "frmWorkOrdersBrowse", acFormDS, , , , acHidden

If IsLoaded("frmWorkOrdersBrowse") Then
Dim F As Form
Set F = Forms!frmWorkOrdersBrowse
F.RecordSource = Me.RecordSource
F.Filter = Me.Filter
F.FilterOn = True
F.OrderBy = Me.OrderBy
F.OrderByOn = True
F.Visible = True
Set F = Nothing
DoCmd.FindRecord Me![WorkOrder#]
End If

End Sub
************************************************** ***********************************
I've tried to just have the code expand the subforms and leave them all
open, just open and close the subforms, and a bunch of variations of
what you gave me and it always locks out the parts.

Thanks,
Ken

Mar 17 '06 #6
I found out what's going on, I'm just not sure how to fix it.

I put the first code you gave me back and still the same results of
course, Parts columns are all blank and the total cost is just a carry
over of the labor.

After looking at this for the last day, I realized that the very first
work order doesn't have any part on it. So for the hell of it I put a
part on the 1st work order and hit browse again. Now instead of all
being blank, they all have the cost of the part on the 1st work order.

The PartsCost points to OrderSubtotal on the subform.
PartsCost =[subfrmWODetailsExtended].[Form]![OrderSubtotal]

This browse form is supposed to be viewed in datasheet but if I open it
in Normal view it works fine.

I'm not sure how to make it look at each part cost instead of just the
first one.

Ken

Mar 17 '06 #7
This is because there is really only one control on a continuous form that
is repeated multiple times. So, when the calculation gets the value from
Textbox1, it gets it from the Textbox1 in the current record. To work around
this, use a query to feed the continuous form and for calculations that you
want to occur on each row, do the calculation in the query as a Calculated
Field and bind what is currently the Calculated Control to this new field.
The query will do the calculation one row at a time and since the control on
the form is now bound, it will display the value for that row.

--
Wayne Morgan
MS Access MVP
"Ken Mylar" <km****@elch.org> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I found out what's going on, I'm just not sure how to fix it.

I put the first code you gave me back and still the same results of
course, Parts columns are all blank and the total cost is just a carry
over of the labor.

After looking at this for the last day, I realized that the very first
work order doesn't have any part on it. So for the hell of it I put a
part on the 1st work order and hit browse again. Now instead of all
being blank, they all have the cost of the part on the 1st work order.

The PartsCost points to OrderSubtotal on the subform.
PartsCost =[subfrmWODetailsExtended].[Form]![OrderSubtotal]

This browse form is supposed to be viewed in datasheet but if I open it
in Normal view it works fine.

I'm not sure how to make it look at each part cost instead of just the
first one.

Ken

Mar 17 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ivan | last post by:
I have a form (CustomerImfo) that has a subform within it (order). Within that subform is another subform (OrderDetail). That subform (OrderDetail) is displayed in Datasheet view. When I am...
4
by: MacDermott | last post by:
I have an Access 2000 form with a subform in Datasheet view. When I click on an item in the header of the subform (the title at the top of one of the columns), I'd like to be able to capture the...
13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
1
by: Richard Sherratt | last post by:
I added a new field to a table in the tables database. In the code database, I added a new column for the new field to a datasheet subform. I opened it in datasheet view and moved the column to the...
5
by: kotowskil | last post by:
A report has a subform. The subform is set to datasheet view and its RecordSource is a select query that includes a memo field from the source table. The memo field's Can Grow property is Yes,...
5
by: sara | last post by:
I haven't been able to find this answer in previous posts; I have a form, with a subform that is displayed in datasheet view, and one field "Item Description" could be from very few to many...
1
by: Thomas Zimmermann | last post by:
I have a form with a subform in datasheet view. Now, I want to trigger a procedure (P1) each time the user selects an entire column (by clicking in the heading) in the subform. The procedure (P1) I...
6
by: Savita23 | last post by:
I am trying to pass a query string from the main form to subform to display records in datasheet view.I tried using the following code in the form_load() event to populate the subform(Child0) ...
2
by: Alan Forsyth | last post by:
That rather long subject says it. In Access97 running on XP - I want to display a Maximized size Form01, then open a Restore size Datasheet View Form02 on top of the first Form. PopUp won't give...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.