How Do I Check Date Control is Filled

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DanicaDear
    Contributor
    • Sep 2009
    • 269

    #1

    How Do I Check Date Control is Filled

    {NeoPa - Split from Hide labels and textboxes}

    Greetings NeoPa. Just when you thought I was gone for good...I'M BACK! Apparently database skills make for good job security because they keep giving me more and more and more. :-) Anyway, on with the problem.

    I tried your code above, here's mine.
    Code:
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
     Me!GalvDate2.Visible = (Me!GalvDate2 > "")
    End Sub
    My error says Run Time Error 13 Type Mismatch.
    I suppose this is because I'm dealing with a date field and the code references an integer??? Thoughts??
    Last edited by NeoPa; Jan 18 '15, 03:49 PM. Reason: Updated to explain move.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Hello Danica my dear :-)

    Your problem here is simply trying to compare a TextBox control containing date data with an empty string. The important word in that last bit is string.

    As TextBox controls contain Nulls when they are not used you can say :
    Code:
    Me.GalvDate2.Visible = Not IsNull(Me.GalvDate2)
    Does this mean that the code I posted in the other thread was imperfect? Yes! Sorry :-(

    PS. It's great to hear from you again. Please do make contact on Skype when you can.
    Last edited by NeoPa; Jan 18 '15, 04:02 PM.

    Comment

    • DanicaDear
      Contributor
      • Sep 2009
      • 269

      #3
      Wh wh whaaaaat??? You posted code that was imperfect?! GET BACK! I love it! LOL

      Ok, this worked!! I applied it to a total of 8 controls (dates, textbox, and a combobox) and all worked. I also applied it to the label.
      For those wondering,
      Code:
      Me.LabelName.Visible = Not IsNull(Me.GalvDate2)
      because if the control is null then I don't need a label. :-)

      Thank you so much, as always!!

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Originally posted by DanicaDear
        DanicaDear:
        Wh wh whaaaaat??? You posted code that was imperfect?! GET BACK! I love it! LOL
        Give me a break girl!! That was posted before you were born almost (22 Jan 2007) :-D

        Actually, almost exactly three months after I joined the site, so very early in my time of concentrating on Access as a speciality.

        Of course I do!

        That's the answer to your follow up question or accusation - "But surely you still make errors even now - even if not very often?".

        We are all learning all the time (If we're still alive). That is just as true for those of us with a lot of experience as it is for those with less. Otherwise it would be pretty boring TBF.

        Always fun :-)

        Comment

        Working...