Results 1 to 6 of 6

Thread: Date problem??

  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date problem??

    I have some code in a birthday report that I would like it to highlight and put a star beside everyone whose birthday is in the current month. So far this is what I have:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    Dim MyDate, MyMonth, MyMonth2, MyDate2
    MyDate = [BirthDate+]
    MyMonth = Month(MyDate)
    MyDate2 = Date
    MyMonth2 = Month(MyDate2)
    If MyMonth2 = MyMonth Then
    Me![BirthDate+].FontBold = True
    Me![BirthDate+].FontName = "Arial Black"
    Me![BirthDate+].FontSize = 12
    Me![BirthDate+].ForeColor = vbRed
    Me![BirthDate+].BackColor = vbYellow
    Me![imggoldstar].Visible = True
    Else
    Me![BirthDate+].FontBold = False
    Me![BirthDate+].FontName = "Arial"
    Me![BirthDate+].FontSize = 9
    Me![BirthDate+].ForeColor = vbBlack
    Me![BirthDate+].BackColor = vbWhite
    Me![imggoldstar].Visible = False
    End If

    End Sub

    It is not working. The birthdays that it is highlighting are 01 and 08 for the month. The current month is 04. Can anyone suggest a way to do this?

  2. #2
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date problem??

    Hello Linda:
    No need for all the parsing: If Month(MyDate) = Month(Date()) should work.

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    La Verne, California, USA
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date problem??

    I think your 4th line should be:

    MyDate2=Date() Using Parenthesis.

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date problem??

    Try changing the statement

    MyDate = [BirthDate+] to

    MyDate = me![BirthDate+]


    Richard Aheron
    raheron@hotmail.com
    Richard

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date problem??

    Thanks - it works!!

  6. #6
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date problem??

    Be careful with naming fields. Using a name BirthDate+ could lead to problems with the + sign.

Posting Permissions

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