Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Visible = False for value in subform (2002/XP)

    I have a form "frmApplicationDataEntry" with a tab control "TabCtl120". One of the tabs "InstalledOn" has a subform "frmApplicationDataEntry_subApplicationInstalledOn " The subform has a yes/no field "ExcludeFromMove". On the tab there is a checkbox field "ckbMigrate". I am trying to set "visible property for ckbMigrate" to false unless the "ExcludeFromMove" field on the subform is Yes (-1). I am unsure as to whether I should include the event on the main form "frmApplicationDataEntry" or on the checkbox "chkMigrate". So far I have the following which is not working:

    Private Sub ckbMigrate_afterUpdate(Cancel As Integer)
    If frmApplicationDataEntry_subApplicationInstalledOn. ExcludeFromMove = -1 Then
    Visible = True
    Else
    Visible = False
    End If
    End Sub

    Any help would be greatly appreciated. Thank you! -scott

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Visible = False for value in subform (2002/XP)

    I'n confused. You have a checkbox on the tab itself, which means on the parent form, and one on the subform? Is the idea to flag the parent record for migration if the subform record has been flagged? Why do you need two checkboxes? In any event, why would you hide it regardless of its value, which is what you seem to be trying to do? The afterupdate event of the checkbox on the tab control isn't the appropriate one to use and you may not be correctly referencing the subform control. Is the subform control named the same as the subform?
    Charlotte

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Visible = False for value in subform (2002/XP)

    In general, a subform contains multiple records. Hence ExcludeFromMove can be Yes for some records in the subform, and No for others. How to determine whether ckbMigrate on the main form should be visible or not?

  4. #4
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visible = False for value in subform (2002/XP)

    Thank you for your reply. I would like ckbMigrate to be visible if any of the values within the field "ExcludeFromMove" (on the subform) have a value of (-1) if that is possible. Thanks. -Scott

  5. #5
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visible = False for value in subform (2002/XP)

    Thank you for your reply. This app is to help manage a server move we are scheduling. There is a yes/no field on the subform indicating the status of whether a server is excluded from moving. We have applications associated with that server. If the server is flagged as not moving (ie. ExcludeFromMove = -1) I want to have an option to select migrate the application. I don't want to see the option to migrate if the server is already moving. Hope that makes sense. To answer your second question yes, the subform control and subform have the same name "frmApplicationDataEntry_subApplicationInstalledOn ". Thank you for your help. - scott

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Visible = False for value in subform (2002/XP)

    This is not so easy. I'll have to think about it; let's hope that somebody else has a ready-made solution.

  7. #7
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visible = False for value in subform (2002/XP)

    I don't feel so bad then ;-)
    Thanks for your help. I appreciate it.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Visible = False for value in subform (2002/XP)

    OK, here you go.

    Put a text box in the form footer of the subform. Set the following properties:

    Visible: No (the user doesn't need to see it)
    Control Source: =Sum([ExcludeFromMove])
    Name: txtSum

    Put the following code in the After Update event of ExcludeFromMove on the subform:

    Private Sub Form_AfterUpdate()
    ' Force txtSum to be updated immediately
    Me.Recalc
    ' Update visibility of check box on main form
    Parent!ckbMigrate.Visible = (Me.txtSum < 0)
    End Sub

    and the following code in the On Current event of the main form:

    Private Sub Form_Current()
    ' Update visibility of check box when moving to another record
    ckbMigrate.Visible = (Me.frmApplicationDataEntry_subApplicationInstalle dOn!txtSum < 0)
    End Sub

    Substitute the appropriate names. Note: frmApplicationDataEntry_subApplicationInstalledOn must be the name of the subform as a control on the main form; this is not necessarily the same as the name in the database window.

  9. #9
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visible = False for value in subform (2002/XP)

    I made the modifications. When I open the form and navigate through records, I get the following message: "The expression On Current you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name." The chkMigrate checkbox remains visible. ?
    Thank you for your help with this. -scott

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Visible = False for value in subform (2002/XP)

    Post your current event code. It sounds like you included an argument that doesn't belong there.
    Charlotte

  11. #11
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visible = False for value in subform (2002/XP)

    Here it is. Thank you.:

    Private Sub Form_Current()
    'Update visibility of check box when moving to another record
    ckbMigrate.Visible = (Me.txtSum < 0)
    End Sub

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Visible = False for value in subform (2002/XP)

    The declaration looks OK.

    I recommended creating a text box txtSum in the subform, and creating an On Current handler for the main form. So Me.txtSum is not correct. See my previous reply.

    Something else to check: in your first post in this thread, you had

    Private Sub ckbMigrate_afterUpdate(Cancel As Integer)

    That is a declaration of the wrong type; Cancel is an argument of Before Update, not of After Update. So if you still have this, change it to

    Private Sub ckbMigrate_AfterUpdate()

  13. #13
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visible = False for value in subform (2002/XP)

    I did create the txtSum box in the footer of the main form with a control source of: =Sum([frmApplicationDataEntry_subApplicationInstalledOn].[Form]![ExcludeFromMove]) and Visible = no

    The rest is as you recommended:
    After update event on Exxclude from move (within frmApplicationDataEntry_subApplicationInstalledOn)

    Private Sub ExcludeFromMove_AfterUpdate()
    'Force txtSum to be updated immediately
    Me.Recalc
    'Update visibility of check box on parent form
    Parent!ckbMigrate.Visible = (Me.txtSum < 0)
    End Sub

    and the Main form On Current event as mentioned in the previous post to Charlotte.
    Sorry for the confusion.
    -Scott

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Visible = False for value in subform (2002/XP)

    1. Temporarily make the text box visible, and see if its value is kept up to date correctly. I doubt it.

    2. If the text box is on the main form, Me.txtSum < 0 in code for the subform is not valid.

    3. Do you still get the error?

  15. #15
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visible = False for value in subform (2002/XP)

    1. Error in text box
    2. I next tried:

    Private Sub ExcludeFromMove_AfterUpdate()
    'Force txtSum to be updated immediately
    Me.Recalc
    'Update visibility of check box on parent form
    Parent!ckbMigrate.Visible = (Me.Forms![frmApplicationDataEntry]![txtSum] < 0)
    End Sub
    To reach it explicitly. Didn't work.
    Still getting the error.

Page 1 of 2 12 LastLast

Posting Permissions

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