Results 1 to 10 of 10
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Conditionally Hiding a Subform Text Box (2003)

    The subform contained in the startup form of the attached mdb opens on the day following the most recent date present in the PortDez23 table. The LETTUR1 text box in the subform should be visible for the day selected on the calendar depending on whether the value for the inLetA field in the DezG2K table is null or zero.
    I thought the following expressions in the Current event for the MG2Dez form should do the job but when the startup form opens on the April 1, 2005 date, the LETTUR1 text box remains visible notwithstanding the fact the inLetA field value for the StartDate closest or equal to the calendar date is null.

    rst.Open "dezg2k", cnn, adOpenKeyset, adLockOptimistic
    rst.MoveFirst
    Do Until rst.EOF
    If (rst!InLetA = 0 Or IsNull(rst!InLetA)) And Giorno >= rst!StartDate Then
    LETTUR1.Visible = False
    Me.Label131.Visible = False
    Else
    LETTUR1.Visible = True
    Me.Label131.Visible = True
    End If

    rst.MoveNext
    Loop

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

    Re: Conditionally Hiding a Subform Text Box (2003)

    Your code loops through all records of dezg2K. In the last record of dezg2K, inletA is not 0 or null (it is 1623,5), so the Else part of the code is executed, making Lettur1 visible, even if it was hidden earlier on. Instead of looping through the recordset, try this:

    Dim d As Date
    Dim i As Variant
    If Not IsNull(Me.Giorno) Then
    d = DMax("StartDate", "dezg2k", "StartDate <= #" & _
    Format(Giorno, "mm/dd/yyyy") & "#")
    i = DLookup("InLetA", "dezg2k", "startDate = #" & _
    Format(d, "mm/dd/yyyy") & "#")
    If (i = 0 Or IsNull(i)) Then
    LETTUR1.Visible = False
    Me.Label131.Visible = False
    Else
    LETTUR1.Visible = True
    Me.Label131.Visible = True
    End If
    End If

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditionally Hiding a Subform Text Box (2003)

    Thank you Hans,
    I'm trying to use the same approach for the attached, similar subform but this time the LETTUR1 text box doesn't get hidden upon opening the startup form. What I am doing wrong?

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

    Re: Conditionally Hiding a Subform Text Box (2003)

    When the form Mazzuno opens, there is no current record, and hence there is no current record in the subform. Giorno is null, so the Lettur1 text box is set to visible.

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditionally Hiding a Subform Text Box (2003)

    Hans,
    I need to understand one thing:
    What makes you say that there is a current record upon opening the Dezzo startup form in the attachment to the starting post? Both forms seem to behave in the same way to me. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

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

    Re: Conditionally Hiding a Subform Text Box (2003)

    I'm just grasping at straws. It has something to do with the Link Master Fields property of the subform being Giorno instead of CData, but I don't really understand what is going on here.

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditionally Hiding a Subform Text Box (2003)

    Thank you Hans,
    Never have straws tasted so good. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    Yet you're right, although substituting Cdata for Giorno makes it work, it's difficult to understand why.

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

    Re: Conditionally Hiding a Subform Text Box (2003)

    Giorno in the subform remains Null each time Form_Current is called, so the code to make Lettur1 invisible is never called. Why? No idea, it's too complicated.

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditionally Hiding a Subform Text Box (2003)

    Hans,
    This time around even setting the Link Master Fields property of the subform to CData doesn't prevent the LETTUR1 text box from remaining visible notwithstanding the fact the inLetA field value for the StartDate closest or equal to the calendar date upon opening the startup form is zero.
    <img src=/S/help.gif border=0 alt=help width=23 height=15>

  10. #10
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditionally Hiding a Subform Text Box (2003)

    I've found that it works properly if I drag(and hide) on the subform the GIORNO field from the subform field list.

Posting Permissions

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