locked
Runtime error 2450 RRS feed

  • Question

  • Hi all,

    I have a form with a subform.

    The main form is linked to a table with data. The subform is linked to a different table with attachments. The two tables are linked to each other with a field that holds the course number.

    On the main form, the user selects a record to edit. I want the corresponding record in the subform to be retrieved, but I get a runtime error 2450, stating that Access cannot find the referenced form.

    I am using code in the "AfterUpdate"procedure of the main form:

    Me.RecordsetClone.FindFirst "[ScheduleID] = " & "'" & Me![Combo0] & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
    Me.RecordsetClone.FindFirst Forms!Frm_CourseScheduleDET_EDIT_SubForm.[Sch_ID] = Me![Combo0]
    Me.Bookmark = Forms!Frm_CourseScheduleDET_EDIT_SubForme.RecordsetClone.Bookmark
    

    I have tried other options as well, but keep getting the same error.

    Any assistance will be appreciated.

    Thanks

    Deon

    
    


    Thursday, January 25, 2018 2:03 PM

Answers

  • Hi Deon SA,

    You had mentioned that,"On the main form, the user selects a record to edit. I want the corresponding record in the subform to be retrieved"

    Do you mean something like below?

    If yes then you can use code like below.

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me!Child11.Form.Filter = "[course _number]= " & Me.coursecombo
    Me!Child11.Form.FilterOn = True
    Me!Child11.Form.Requery
    End Sub
    

    Just for a demo i use Form_BeforeUpdate event, you use Form_AfterUpdate event.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Deon SA Friday, January 26, 2018 5:40 AM
    Friday, January 26, 2018 3:00 AM

All replies

  • Me.RecordsetClone.FindFirst "[ScheduleID] = " & "'" & Me![Combo0] & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
    Me.RecordsetClone.FindFirst Forms!Frm_CourseScheduleDET_EDIT_SubForm.[Sch_ID] = Me![Combo0]
    Me.Bookmark = Forms!Frm_CourseScheduleDET_EDIT_SubForme.RecordsetClone.Bookmark

    Hi Deon,

    "Me"  refers to the main form (I suppose, because of the Combo0), so you can't use it for the subform.

    You can define a subform-form object

        Dim subx_form as Form

        Set subx_form = Me(<subformcontrolname>).Form

    and from then on use subx_form instead of Me for the synchronization.

    Imb.

    Thursday, January 25, 2018 2:22 PM
  • Are the master-child links set up properly between your main form and subform?  In most cases, no additional code is needed for the subform to respond when the mainform record changes - it will automatically filter to records according to the linked field.  Have you tried just this?

    Me.RecordsetClone.FindFirst "[ScheduleID] = " & "'" & Me![Combo0] & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark

    Also, IF scheduleID is a numeric field, omit the single quotes:

    Me.RecordsetClone.FindFirst "[ScheduleID] = " & Me![Combo0] 


    Miriam Bizup Access MVP

    Thursday, January 25, 2018 2:56 PM
  • Hi Deon SA,

    You had mentioned that,"On the main form, the user selects a record to edit. I want the corresponding record in the subform to be retrieved"

    Do you mean something like below?

    If yes then you can use code like below.

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me!Child11.Form.Filter = "[course _number]= " & Me.coursecombo
    Me!Child11.Form.FilterOn = True
    Me!Child11.Form.Requery
    End Sub
    

    Just for a demo i use Form_BeforeUpdate event, you use Form_AfterUpdate event.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Deon SA Friday, January 26, 2018 5:40 AM
    Friday, January 26, 2018 3:00 AM
  • Hi all,

    Thanks for the responses and advise.

    The problem was that I never linked the Master - Child links. It now works.

    Much appreciated.

    Deon

    Friday, January 26, 2018 5:40 AM
  • The problem was that I never linked the Master - Child links.

    Hi Deon,

    Did you mark the correct answer?


    Miriam Bizup Access MVP

    Friday, January 26, 2018 1:16 PM