Code error that nested form control not found

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PamelaP
    New Member
    • Aug 2012
    • 3

    Code error that nested form control not found

    I have a nested forms 5 deep. The code is on the After Update event of a combo box control on the 1st Parent form. The intention is that when a user selects #2 from the drop-down on that first form, that certain controls in the nested forms will be disabled. The code works correctly for all of the controls except for the ShopName control (the last in the list). If I add a " ' " to the front of the line to make it a note, everything else works. The controls are all on the same subform and I've double-checked to make sure the control name is correct. Please help!

    Code:
    Private Sub FileType_AfterUpdate()
    If (Me.FileType = "2") Then
    Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!Days.Enabled = False
    
    Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!TotalLoss.Enabled = False
    
    Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!lbPartCo.Enabled = False
    
    Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!Command24.Enabled = False
    
    Me!sfrmInspection.Form!sfrmLocation.Form!frmDamage.Form!sfrmEstimate.Form!ShopName.Enabled = False
    End If
    End Sub
    Thank you so much!
    Last edited by zmbd; Aug 16 '12, 06:21 PM. Reason: Inserted required code tags.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    Pamela,

    Try renaming the text box to txtShopName and then point to that control in your code (as a reminder, please use the code tags when you post).

    This "should not" be the cause of the error, but I find it is always a good practice to name the control on the form with a prefix (such as txt for a text box or cbo for a combo box), that way you (and others coming after you) are clear that you are talking about hte control and not the field underlying the control.

    I don't know if this will fix it, but give it a try. Stranger things have happened in Access.....

    Comment

    • PamelaP
      New Member
      • Aug 2012
      • 3

      #3
      Thanks for the tip. This db has been a long time in the works and so as I've begun to learn more, I've adapted some of these tips but my biggest concern in going back through and renaming is that it will then create a problem for other code that I have running. I don't know of a way to go back through and search every instance of where that control name would be in my db to update them also.


      Originally posted by twinnyfo
      Pamela,

      Try renaming the text box to txtShopName and then point to that control in your code (as a reminder, please use the code tags when you post).

      This "should not" be the cause of the error, but I find it is always a good practice to name the control on the form with a prefix (such as txt for a text box or cbo for a combo box), that way you (and others coming after you) are clear that you are talking about hte control and not the field underlying the control.

      I don't know if this will fix it, but give it a try. Stranger things have happened in Access.....

      Comment

      Working...