F
Freeflyer
Hi,
I have a confusing problem when I try to obtain the RecordCount of a new
record.
I have a main form with two tabbed pages, one of which contains a subform.
If the subform has any records I wish to show that tab, otherwise I want the
other tab to display. I have the following code in the OnCurrent event of the
main form so that it is triggered everytime a new record is displayed.
If Me!sfrmQuoteDetail.Form.Recordset.RecordCount = 0 Then
Me.tabQuote.Value = 0
Else
Me.tabQuote.Value = 1
End If
This code works fine for me normally. If I open the form I see the correct
tab (tab1 usually) and when I navigate to a new record it shows tab0.
However, I then added the following code to the OnOpen event so that the form
would default to a new record.
Private Sub Form_Open(Cancel As Integer)
' On opening, go to new record
DoCmd.GoToRecord , , acNewRec
End Sub
Now I get an error message everytime I try to open the form:
"Runtime Error 2455: you entered an expression that has an invalid reference
to the property Form/Report."
Any idea why going straight to a new record should trigger this when opening
on an existing record before going to a new record does not?
I have a confusing problem when I try to obtain the RecordCount of a new
record.
I have a main form with two tabbed pages, one of which contains a subform.
If the subform has any records I wish to show that tab, otherwise I want the
other tab to display. I have the following code in the OnCurrent event of the
main form so that it is triggered everytime a new record is displayed.
If Me!sfrmQuoteDetail.Form.Recordset.RecordCount = 0 Then
Me.tabQuote.Value = 0
Else
Me.tabQuote.Value = 1
End If
This code works fine for me normally. If I open the form I see the correct
tab (tab1 usually) and when I navigate to a new record it shows tab0.
However, I then added the following code to the OnOpen event so that the form
would default to a new record.
Private Sub Form_Open(Cancel As Integer)
' On opening, go to new record
DoCmd.GoToRecord , , acNewRec
End Sub
Now I get an error message everytime I try to open the form:
"Runtime Error 2455: you entered an expression that has an invalid reference
to the property Form/Report."
Any idea why going straight to a new record should trigger this when opening
on an existing record before going to a new record does not?