R
Roderick de Rijke via AccessMonster.com
I am trying to calculate values in a form based on the values of 4
subforms. It did work, it is to say only when all the fields in the
subforms contain a value. Therefor i am trying to write a code to check if
there are any values in the txtfields in the subforms.
I wrote this code only i already stops at the first rst.MoveFirst. Can
somebody please help me out on this one.
Many thanks Roderick Spain
Here is my code:
Private Sub Update_Click()
Dim TxtTotaalActiviteiten As Long, TxtTotaalLogies As Long,
TxtTotaalGastronomia As Long, TxtTotaalExtras As Long
Dim rst As Recordset
Set rst = Forms![FrmMainform]![Subformulario Presupuesta1]
..Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalActiviteiten = Forms![FrmMainform]![ Subformulario Presupuesta1]
..Form.GrantotalActividadesConIva
Else
TxtTotaalActiviteiten = 0
End If
Me!GrantotalActividadesConIva = TxtTotaalActiviteiten
Set rst = Forms![FrmMainform]![ Subformulario AlojamientoHD]
..Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalLogies = Forms![FrmMainform]![ Subformulario AlojamientoHD]
..Form.GrantotalAlojamentoConIva
Else
TxtTotaalLogies = 0
End If
Me!GrantotalAlojamentoConIva = TxtTotaalLogies
Set rst = Forms![FrmMainform]![ Subformulario Gastronomia eerste gang1]
..Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalGastronomia = Forms![FrmMainform]![ Subformulario Gastronomia
eerste gang1].Form.GrantotalGastronomiaConIva
Else
TxtTotaalGastronomia = 0
End If
Me!GrantotalGastronomiaConIva = TxtTotaalGastronomia
Set rst = Forms![FrmMainform]![ Subformulario Extras].Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalExtras = Forms![FrmMainform]![Subformulario Extras]
..Form.GrantotalExtraConIva
Else
TxtTotaalExtras = 0
End If
Me!GrantotalExtraConIva = TxtTotaalExtras
rst.Close
End Sub
subforms. It did work, it is to say only when all the fields in the
subforms contain a value. Therefor i am trying to write a code to check if
there are any values in the txtfields in the subforms.
I wrote this code only i already stops at the first rst.MoveFirst. Can
somebody please help me out on this one.
Many thanks Roderick Spain
Here is my code:
Private Sub Update_Click()
Dim TxtTotaalActiviteiten As Long, TxtTotaalLogies As Long,
TxtTotaalGastronomia As Long, TxtTotaalExtras As Long
Dim rst As Recordset
Set rst = Forms![FrmMainform]![Subformulario Presupuesta1]
..Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalActiviteiten = Forms![FrmMainform]![ Subformulario Presupuesta1]
..Form.GrantotalActividadesConIva
Else
TxtTotaalActiviteiten = 0
End If
Me!GrantotalActividadesConIva = TxtTotaalActiviteiten
Set rst = Forms![FrmMainform]![ Subformulario AlojamientoHD]
..Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalLogies = Forms![FrmMainform]![ Subformulario AlojamientoHD]
..Form.GrantotalAlojamentoConIva
Else
TxtTotaalLogies = 0
End If
Me!GrantotalAlojamentoConIva = TxtTotaalLogies
Set rst = Forms![FrmMainform]![ Subformulario Gastronomia eerste gang1]
..Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalGastronomia = Forms![FrmMainform]![ Subformulario Gastronomia
eerste gang1].Form.GrantotalGastronomiaConIva
Else
TxtTotaalGastronomia = 0
End If
Me!GrantotalGastronomiaConIva = TxtTotaalGastronomia
Set rst = Forms![FrmMainform]![ Subformulario Extras].Form.RecordsetClone
rst.MoveFirst
rst.MoveLast
If Nz(rst.RecordCount, 0) > 0 Then
TxtTotaalExtras = Forms![FrmMainform]![Subformulario Extras]
..Form.GrantotalExtraConIva
Else
TxtTotaalExtras = 0
End If
Me!GrantotalExtraConIva = TxtTotaalExtras
rst.Close
End Sub