carylrahn said:
Hi Dirk,
I sent you the file to your email as requested. Let me know if you do
not get it.
Got it, Caryl, and I see what's happening. You didn't mention
everything that you are doing on that form. You have the following
event procedures relating to the subform controls on that form:
Private Sub sfA_Enter()
Me.sfB.SourceObject = "fBlank"
Me.sfA.SourceObject = "fA"
End Sub
Private Sub sfB_Enter()
Me.sfA.SourceObject = "fBlank"
Me.sfB.SourceObject = "fB"
End Sub
In other words, you are using the Enter event of the subform control to
reset the subform control's SourceObject property. That's a bit odd, to
my way of thinking, but that alone wouldn't be crashing Access. But
when you click the Print button (not on the subform) to open the report,
then close the report and click the scroll bar on the subform, the Enter
event of the subform control fires again. That leaves the subform
trying to process the scroll message, at the same time the Enter event
is trying to replace it with ... itself. Apparently Access gets
hopelessly confused at this point, and crashes. Any time the program
crashes, it's a bug, of course -- but I'm not really surprised at this
one.
Was it your intention to swap subforms as you switch pages? I would
just use the tab control's Change event for that; e.g.,
Private Sub TabCtl0_Change()
Select Case Me.TabCtl0.Value
Case 0
Me.sfB.SourceObject = "fBlank"
Me.sfA.SourceObject = "fA"
Case 1
Me.sfA.SourceObject = "fBlank"
Me.sfB.SourceObject = "fB"
End Select
End Sub
Then, since the first page is going to be the initial value of the tab
control, I'd set the initial SourceObject of sfA to "fA", so that "fA"
will be displayed when the form first opens. I believe this approach
will put an end to your crashes while giving you what I think you want.
If, on the other hand, you want to continue with your current approach,
you can put an If statement into your Enter event procedures to
forestall the problem:
Private Sub sfA_Enter()
If Me.sfA.SourceObject <> "fA" Then
Me.sfB.SourceObject = "fBlank"
Me.sfA.SourceObject = "fA"
End If
End Sub
Private Sub sfB_Enter()
If Me.sfA.SourceObject <> "fB" Then
Me.sfA.SourceObject = "fBlank"
Me.sfB.SourceObject = "fB"
End If
End Sub
However, I really think using the tab control's Change event is the
better way to go.