Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006
    Mount Wolf, PA

    Exclamation Unanswered: SubForm Object Closed

    Access 2003 database being updated using Access 2007 on Windows XP Ver 5.1.2600

    I have a drop down menu that populates the form chosen into a sub form named chdSubForm. When I press the retrieve button on the form that has opened inside chdSubForm I receive a message, “The expression you entered refers to an object that is closed or does not exist.”

    Example: I choose from the drop down menu: Address Change – Base 24.

    The form “frm_Masterfile_AdrsChange_Base24)” populates in “chdSubForm” within the main form “frm_Masterfile_1Audits”.

    I have a button on “frm_Masterfile_AdrsChange_Base24” that should bring back data to that form and the main form “frm_Masterfile_1Audits”.

    The data, based on the record ID, *will* populate on the form “frm_Masterfile_1Audits”, but I receive the following error when attempting to populate data on the form “frm_Masterfile_AdrsChange_Base24” (This is the form with the retrieve button) “The expression you entered refers to an object that is closed or does not exist.”

    Code for Retrieve button on “frm_Masterfile_AdrsChange_Base24”:

    Dim AuditID As Long, AuditType As Integer
    Dim db As Database, RS1 As Recordset

    Set db = CurrentDb()
    Set RS1 = db.OpenRecordset("tbl_Masterfile_Audits", dbOpenDynaset)

    AuditID = Nz(Forms!frm_Masterfile_1Audits!txtAuditID.Value)

    RS1.FindFirst "ID " & "=" & AuditID & " "

    If RS1.NoMatch = True Then
    Exit Sub

    ***This data *is* returned to the main form with this code:
    Forms!frm_Masterfile_1Audits!txtAuditorName.Value = RS1!Auditor
    Forms!frm_Masterfile_1Audits!cboEmpName.Value = RS1!EmpID
    Forms!frm_Masterfile_1Audits!txtMerchantNumber.Val ue = RS1!MerchNum

    ***This code is highlighted with this error message: “The expression you entered refers to an object that is closed or does not exist.”
    txtAC_MSTAddress.Value = RS1!txtAC_MSTAddress.Value
    txtAC_MSTCity.Value = RS1!txtAC_MSTCity.Value

    I tried:
    [Forms]![frm_Masterfile_AdrsChange_Base24]!txtAC_MSTAddress.Value = RS1!txtAC_MSTAddress.Value
    [Forms]![frm_Masterfile_AdrsChange_Base24]!txtAC_MSTCity.Value = RS1!txtAC_MSTCity.Value


    [Forms]![frm_chdSubForm]!txtAC_MSTAddress.Value = RS1!txtAC_MSTAddress.Value
    [Forms]![frm_chdSubForm]!txtAC_MSTCity.Value = RS1!txtAC_MSTCity.Value

    Both generate the error: database cannot find form ‘form name here’ referred to in visual basic code.

    End If

  2. #2
    Join Date
    Feb 2004
    Chicago, IL
    Subform syntax is a little weird. You almost have it right. Keep in mind the Forms collection stores all of the forms that are currently open. When you open a form as a subform it is NOT an open form. Instead it is now a control on the open form. To access the subform controls you need to drill down to the controls through the open form like this:

    [Forms]![frm_Masterfile_1Audits].chdSubForm.Form.Controls("txtAC_MSTCity").Value = RS1!txtAC_MSTCity.Value

    or, I prefer if the code is in the frm_Masterfile_1Audits module:


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts