M
Michael Banks
I have some code that displays a subform based on the recordset
available.
The code counts up the recordset and if it is greater than 1, displays
the subform. Problem is that this only happens when I insert a
Breakpoint at the start of the code. If the breakpoint is not in place
then the code doesn't perform correctly.
Here is the code:
Dim EquipmentCount As Integer
EquipmentCount = 0
EquipmentCount =
Forms!frmtransformers![subfrmTransformers].Form.RecordsetClone.RecordCount
'Not counting this properly
Debug.Print "EquipmentCount is " & EquipmentCount
If EquipmentCount > 0 Then
Forms!frmtransformers!subfrmTransformers.Form.Visible = True
Else
Forms!frmtransformers!subfrmTransformers.Form.Visible = False
End If
Debug.Print "Transformers at " & Forms!frmtransformers!cboService_Center
& " " & Forms!frmtransformers!cboSubstation_Name & " is " &
Forms!frmtransformers!subfrmTransformers.Form!.RecordsetClone.RecordCount
EquipmentCount = 0
I am resetting the EquipmentCount before and after the code is ran, that
doesn't seem to help me though.
If I put in a Breakpoint at the line EquipmentCount = 0 then the code
works correctly, i.e. my debug.prints would be:
EquipmentCount is 4
Transformers at SBY ADAMS is 4
And the subform is visible.
If I don't have a breakpoint insterted then I get:
EquipmentCount is 0
Transformers at SBY ADAMS is 0
And the subform isn't visible.
I am confused as to why this happens. Please offer up opinions.
Thanks
Mike
available.
The code counts up the recordset and if it is greater than 1, displays
the subform. Problem is that this only happens when I insert a
Breakpoint at the start of the code. If the breakpoint is not in place
then the code doesn't perform correctly.
Here is the code:
Dim EquipmentCount As Integer
EquipmentCount = 0
EquipmentCount =
Forms!frmtransformers![subfrmTransformers].Form.RecordsetClone.RecordCount
'Not counting this properly
Debug.Print "EquipmentCount is " & EquipmentCount
If EquipmentCount > 0 Then
Forms!frmtransformers!subfrmTransformers.Form.Visible = True
Else
Forms!frmtransformers!subfrmTransformers.Form.Visible = False
End If
Debug.Print "Transformers at " & Forms!frmtransformers!cboService_Center
& " " & Forms!frmtransformers!cboSubstation_Name & " is " &
Forms!frmtransformers!subfrmTransformers.Form!.RecordsetClone.RecordCount
EquipmentCount = 0
I am resetting the EquipmentCount before and after the code is ran, that
doesn't seem to help me though.
If I put in a Breakpoint at the line EquipmentCount = 0 then the code
works correctly, i.e. my debug.prints would be:
EquipmentCount is 4
Transformers at SBY ADAMS is 4
And the subform is visible.
If I don't have a breakpoint insterted then I get:
EquipmentCount is 0
Transformers at SBY ADAMS is 0
And the subform isn't visible.
I am confused as to why this happens. Please offer up opinions.
Thanks
Mike