Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: 2455 - You entered an expression that has an invalid reference

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I have the following code on the OnCurrent event of the a subform.
Code:
Me.Parent.cboLeadID = Me.LeadID
Forms!frmDriller!frmDrillerSubForm.Requery
Forms!frmDriller!frmNotesSub.Requery
If Forms!frmDriller!frmDrillerSubForm!chkJoint = True Then
Forms!frmDriller!pgJointDetails.Visible = True
Forms!frmDriller!frmDrillerSubForm.Form!LeadsLabel.Caption = Forms!frmDriller!frmDrillerSubForm.Form!Title & " " & Forms!frmDriller!frmDrillerSubForm.Form!Firstname & " " & Forms!frmDriller!frmDrillerSubForm.Form!Surname & " " & "&&" & " " & Forms!frmDriller!Child106.Form!Title & " " & Forms!frmDriller!Child106.Form!Firstname & " " & Forms!frmDriller!Child106.Form!Surname

Else
If IsNull(Forms!frmDriller!frmDrillerSubForm!chkJoint) Then
Forms!frmDriller!pgJointDetails.Visible = False
Forms!frmDriller!frmDrillerSubForm.Form!LeadsLabel.Caption = Forms!frmDriller!frmDrillerSubForm.Form!Title & " " & Forms!frmDriller!frmDrillerSubForm.Form!Firstname & " " & Forms!frmDriller!frmDrillerSubForm.Form!Surname

End If
End If

This determines which record gets displayed on another subform. However, when I open the parent form I get the error, you entered an expression that has an invalid reference...

I have added the code to the onload event as well to the subform that filters out the records
 
How are ya primagic . . .

Be aware: when a mainform with subform(s) opens, it opens from the [blue]innermost subform out to the mainform[/blue]. This means when the subform(s) are open, the mainform isn't open yet and of course [blue]any references to the mainform fail![/blue]

As a first shot at this try your code in the [blue]On Load[/blue] event of the mainform only! remove or rem out otyher code you've tried. Keep in mind you have to change your form referencing since the code is now running from the mainform:
Code:
[blue]   Dim sfDril As Form, sfNote As Form, sf106 As Form
   
   Set sfDril = [frmDrillerSubForm].Form
   Set sfNote = [frmNotesSub].Form
   Set sf106 = [Child106].Form
   Me.cboLeadID = sfDril.LeadID
   
   If sfDril!chkJoint Then
      sfDril!pgJointDetails.Visible = True
      sfDril!LeadsLabel.Caption = sfDril!Title & " " & _
                                  sfDril!Firstname & " " & _
                                  sfDril!Surname & " " & _
                                  "&&" & " " & _
                                  sf106!Title & " " & _
                                  sf106!Firstname & " " & _
                                  sf106!Surname
   ElseIf IsNull(sfDril!chkJoint) Then
      Me!pgJointDetails.Visible = False
      sfDril!LeadsLabel.Caption = sfDril!Title & " " & _
                                  sfDril!Firstname & " " & _
                                  sfDril!Surname
   End If

   Set sf106 = Nothing
   Set sfNote = Nothing
   Set sfDril = Nothing[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top