Results 1 to 3 of 3
  1. #1
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92

    My form is not displaying dates in the correct format

    Hey everyone. On one of my forms, I have it show several dates (each date during the week) based on a field where the user inputs a date. Bascially, I have a field called WeekEnding, and based on what goes in there, it puts a date in seven other fields: D1Date, D2Date, D3Date, D4Date, D5Date, D6Date, and D7Date.



    On the Table where they live, I have set them all to the Date/Time type. For WeekEnding, I am using the predetermined date format: m/d/yyyy. For the others, I don't need to see the year, so I have made a custom format in the Table Design View: m/d

    In D1Date, the custom format shows up correctly on my Form. However, on the others, it does not. It continues to show the year as well. The very weird thing is, in the Table itself, the date listed in those fields do NOT have the year on them, so inside the table itself, the format is correct. Anyone have any idea why this would be happening?

    Here is the code I'm using to input the dates into the fields, and below that are a couple of screenshots.

    Code:
    Private Sub WeekEnding_AfterUpdate()
    
    Me.D1Date = DateAdd("d", -6, Me.WeekEnding)
    Me.D2Date = DateAdd("d", -5, Me.WeekEnding)
    Me.D3Date = DateAdd("d", -4, Me.WeekEnding)
    Me.D4Date = DateAdd("d", -3, Me.WeekEnding)
    Me.D5Date = DateAdd("d", -2, Me.WeekEnding)
    Me.D6Date = DateAdd("d", -1, Me.WeekEnding)
    Me.D7Date = Me.WeekEnding
    
    End Sub
    Here's the table. You can see the dates inside D2Date are in the format that I want. The same is true for all the other dates: D1Date, D3Date, etc.

    Click image for larger version. 

Name:	TableViewOfD2Date.jpg 
Views:	11 
Size:	120.1 KB 
ID:	31095

    Here's the Form. You can see D1Date has the correct format (no year at the end), but the others are not correct; they are still displaying the year. That's why the #### are inside those boxes, because they don't fit with the additional characters. (D2Date is the one directly under the one that has "10/29" inside. D3Date is directly under that one, and so on.)

    Click image for larger version. 

Name:	FormWithDateNotDisplayingCorrectly.jpg 
Views:	11 
Size:	180.8 KB 
ID:	31096

    I can't figure this one out. Please let me know if you have any ideas.

  2. #2
    Join Date
    Apr 2017
    Posts
    1,689
    Check the format of control on form, displaying the date.

    In general, you can set date formats in tables, but you can drop this at all too. Form controls are where formatting is MUST.

  3. #3
    mcomp72 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    92
    That was it! I figured if I changed it in the Table it would automatically do it on the Form as well. Guess that isn't always the case, but weird it worked on D1Date but not the others.

    Thanks for the help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form not displaying correct record
    By shadowsedge in forum Forms
    Replies: 2
    Last Post: 04-04-2016, 11:38 AM
  2. Replies: 1
    Last Post: 11-10-2013, 05:25 PM
  3. Replies: 3
    Last Post: 08-15-2013, 10:43 AM
  4. Replies: 2
    Last Post: 11-19-2012, 10:54 AM
  5. Correct code for challenging dates?
    By thekruser in forum Queries
    Replies: 6
    Last Post: 11-08-2010, 03:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums