Results 1 to 12 of 12

Thread: Hide a text box

  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Hide a text box

    Ha-ha, I always crack myself up when I attempt anything resembling code, but just so you know that I actually took a stab at this, here we go:

    I want to hide a text box ("Reorder") when ever there is a date entry in text box "Refill Req". I have three different conditional formats for Refill Req or I could really simplifiy this. So I'm stuck with doing something with code. This is what I have (don't laugh, at least not to where I can hear you).

    Private Sub Form_Current()
    'Disable Reorder text box if there is
    'a Refill Req date entered

    Dim stDocName As String

    stDocName = "FrmCon_Rx Edit"

    If [Refill Req] = IsNull Then
    [Reorder].Visible = True
    Else
    [Reorder].Visible = False
    End If
    End Sub


    AND

    Private Sub Refill_Req_AfterUpdate()
    'Disable Reorder text box if there is
    'a Refill Req date entered

    Dim stDocName As String

    stDocName = "FrmCon_Rx Edit"

    If [Refill Req] = IsNull Then
    [Reorder].Visible = True
    Else
    [Reorder].Visible = False
    End If

    End Sub



    PROBLEM: I'm getting an "Argument not optional" error when loading the form and/or updating the date entry, and it also doesn't change anything (the text box is still visible). Also, I have lost conditional formatting for "Reorder" text box.

    Any help greatly appreciated as always.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    Try changing this:
    If [Refill Req] = IsNull Then

    to
    If IsNull([Refill Req]) = True Then

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Brian,

    You can actually accomplish this in one line:
    [Reorder].Visible = IsNull([Refil Req])

    Since IsNull() will return True or False it can be used as the value for the Visible property.

    If the conditions are reversed just use ...= Not IsNull().
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Not sure if this is the whole problem, but 'IsNull' is a function, not a value.
    So you need
    If IsNull([Refill Req]) Then

    Note that Null is a weird thing - this gives no errors but doesn't work:
    If [Refill Req] = Null Then

    Peter

  5. #5
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Thanks Pat, that resolved the issue as I described it.
    Unfortunately I forgot, and therefor neglected to mention, that this is a continuous form. So, all of the records have the text box hidden regardless of the Null factor. Krap!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Quote Originally Posted by peterl View Post
    'IsNull' is a function, not a value.
    So you need
    If IsNull([Refill Req]) Then
    Peter
    Peter,

    Yes, it is a function but a function that returns a value of True or False.

    Code:
    Private Sub ContractNo_AfterUpdate()
    
      Me.Location.Visible = Not IsNull(Me.ContractNo)
      Me.Label0.Visible = Not IsNull(Me.ContractNo)
       
    End Sub
    Yeilds: See graphic.
    Attached Images Attached Images
    Last edited by RetiredGeek; 2011-07-20 at 19:56.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. The Following User Says Thank You to RetiredGeek For This Useful Post:

    bfxtrfcmgr (2011-07-20)

  8. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by bfxtrfcmgr View Post
    Thanks Pat, that resolved the issue as I described it.
    Unfortunately I forgot, and therefor neglected to mention, that this is a continuous form. So, all of the records have the text box hidden regardless of the Null factor. Krap!
    For a Continuous Form you can use Conditional Formatting to enable /disable a control (without any code.)Conditionalenable.gif


    Note that Null is a weird thing - this gives no errors but doesn't work:
    If [Refill Req] = Null Then
    But you can say:

    Code:
    If [Refill Req] is Null Then
    Regards
    John



  9. The Following 2 Users Say Thank You to johnhutchison For This Useful Post:

    bfxtrfcmgr (2011-07-20),RetiredGeek (2011-07-20)

  10. #8
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    John,

    You da Man!
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  11. The Following User Says Thank You to RetiredGeek For This Useful Post:

    bfxtrfcmgr (2011-07-20)

  12. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by bfxtrfcmgr View Post
    Ha-ha, I always crack myself up when I attempt anything resembling code...don't laugh, at least not to where I can hear you
    Any help greatly appreciated as always.
    Just for feedback, (although it's a bit late), but I find it easier to have field names that don't have any spaces - makes them easier to work with.

  13. #10
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Thanks John, as I mentioned, I already was using the permissible three (3) Conditional Formatting options, so I guess I will have to abandon the least vital one to utilize this.

    Thanks again for the input (and lesson); also, a tip of the hat to everyone else as well. Much appreciated!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  14. #11
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Quote Originally Posted by bfxtrfcmgr View Post
    Thanks John, as I mentioned, I already was using the permissible three (3) Conditional Formatting options,
    Sorry I did not notice that bit.
    Regards
    John



  15. #12
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts
    No worries mate!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Posting Permissions

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