G
Guest
I have a form, called frmOrders, for entering data for orders from a
supplier. frmOrders has 2 subforms, one for supplies and one for merchandise
for resale, (subfSupplies & subfMerch). frmOrders is based on a table
tblOrders. subfSupplies & subfMerch are based on tables tblOrderSupplies &
tblOrderMerch respectively. The tables are linked in a one to many
relationship based on Order_No – one side is tblOrders, many side for
tblOrderSupplies & tblOrderMerch.
I use calculated controls in the footer of each subform e.g. for subfSupplies:
=IIf(IsNull(Sum([Cost_Supply]*[Qty_Supply])),0,Sum([Qty_Supply]*[Cost_Supply]))
is the data source for the control SumTotalSupplies in the sub form to total
the supplies. I use the IsNull function in case the order is only for
Merchandise and no supplies were purchased.
To get totals for the main form, a control on the main form (Tot_Supplies)
has the data source: =[subfSupplies].Form!SumTotalSupplies.
All works fine when I open the main form in Add mode from a macro for
entering a new order.
I then tried creating a form, frmViewOrders, which opens in “Read Only†mode
from a macro to be able to review order information. The problem is that if
an order is only for merchandise, then the sub form for supplies is empty (&
vice versa) and I get #error in the main form control. I tried using IFF
(IsNull(…)) in the main form control & it doesn’t work. I then tried adding
code to the “On Current†event of the main form similar to:
Dim recClone As Recordset
Set recClone = “SOMETHINGâ€.RecordsetClone
If recClone.RecordCount = 0 Then
Me.Tot_Supplies = 0
End If
where I tried everything I could think of for “SOMETHINGâ€. Everything I
tried either resulted in a run time error or the same #error in the main form
control.
Maybe a query is the answer???
Any help would be greatly appreciated.
Thanks, Garry Gross
supplier. frmOrders has 2 subforms, one for supplies and one for merchandise
for resale, (subfSupplies & subfMerch). frmOrders is based on a table
tblOrders. subfSupplies & subfMerch are based on tables tblOrderSupplies &
tblOrderMerch respectively. The tables are linked in a one to many
relationship based on Order_No – one side is tblOrders, many side for
tblOrderSupplies & tblOrderMerch.
I use calculated controls in the footer of each subform e.g. for subfSupplies:
=IIf(IsNull(Sum([Cost_Supply]*[Qty_Supply])),0,Sum([Qty_Supply]*[Cost_Supply]))
is the data source for the control SumTotalSupplies in the sub form to total
the supplies. I use the IsNull function in case the order is only for
Merchandise and no supplies were purchased.
To get totals for the main form, a control on the main form (Tot_Supplies)
has the data source: =[subfSupplies].Form!SumTotalSupplies.
All works fine when I open the main form in Add mode from a macro for
entering a new order.
I then tried creating a form, frmViewOrders, which opens in “Read Only†mode
from a macro to be able to review order information. The problem is that if
an order is only for merchandise, then the sub form for supplies is empty (&
vice versa) and I get #error in the main form control. I tried using IFF
(IsNull(…)) in the main form control & it doesn’t work. I then tried adding
code to the “On Current†event of the main form similar to:
Dim recClone As Recordset
Set recClone = “SOMETHINGâ€.RecordsetClone
If recClone.RecordCount = 0 Then
Me.Tot_Supplies = 0
End If
where I tried everything I could think of for “SOMETHINGâ€. Everything I
tried either resulted in a run time error or the same #error in the main form
control.
Maybe a query is the answer???
Any help would be greatly appreciated.
Thanks, Garry Gross