Results 1 to 8 of 8
  1. #1
    UserX is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    30

    Listbox won't display time correctly


    This is driving me nuts. I can't figure out what the damn problem is. What I want is for the "Time In" column in the listbox to show the time as hh:mm, just like the other two. The listbox is pointing to the table correctly, as evidenced by all the data showing up, but what floors me is despite the "sign_in" table showing time in all three columns in the desired format of hh:mm, the listbox seems to have its own thoughts about how to display the called data. Will someone please help me understand this?
    Attached Files Attached Files

  2. #2
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    Perhaps you should use Date/Time for the time fields and then give them the format you want them to have. At the moment it is possible to store the value 1000 and it will be displayeed as 19:59 because of the format you applied. But the format is not evaluated when using a listbox. Therefor the listbox displays the real value in the table field without formating. And looking at your table, the Time_in field is stored without the : whereas the other two fields data contain a :

  3. #3
    UserX is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    30
    I had orginially started with the three time fields set as Date/Time at the table, but because of the "Purpose_of_Visit_Exit" code, Access would spit out errors at me; something about the value being invalid. Also, with the Date/Time specification, the time is displayed as HH:MM:SS AM/PM - takes up too much space, IMO. As a result, I opted for the fields being set as Text.

    While I do appreciate your response, I suspect you didn't actually look at the table, as you would have seen the reason for my posting. The table shows the time in all three columns with the HH:MM format; however, the listbox shows the Time In column as a general number, despite the formatting on the table. Thus I'm very perplexed as to why all fields, with the exception of Time In, appear the same as the table.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Why is the full time display in table a concern? The date/time can be formatted in form or report for shorter displays.

    Do you understand that a date/time value in a date/time field is really a long integer value, not actually the text string that shows?

    I get errors trying to open the forms "Code must be updated for use on 64-bit systems."

    I change the 19:59 value to a 10:59 and it displays the way you want on form. I changed 11:11 to 19:11 and also displays the way you want. So I changed 10:59 back to 19:59 and it now displays correctly. This tells me the 19:59 did not get saved with the :. Did you set input masks after the record was created?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    There is a difference between Time_In and the other two times. In the after update event of Purpose_of_visit, you are assigning a default value to the Time_In field, and I think your code is messing up the value stored (even though it looks OK). If you re-type a new time in that box, it is stored correctly.

    I replaced all the code in that On Exit event with one line: Time_In = Format(Time(), "HH:MM")

    and it works fine, giving me the military time, and it saves that value properly as well.

    Making that change should solve your problem.


    When you are writing VBA code, do you compile it after EVERY change? If not, you should; I got two compilation errors, for an undefined function (StartToolTips).

  6. #6
    UserX is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    30
    The table isn't the concern at all. I wanted to call attention that the table shows what I want, therefore the listbox should as well, since it's supposed to mirror what is on the table. I did notice the time appearance would change, too, but not until after i posted my inquiry. I've set input masks before and after creating records, that didn't change a thing.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Can you post the rowsource SQL?

  8. #8
    UserX is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    30
    John,

    Yes, bunch of code was in fact a problem. I was over complicating it. After deleting the "Purpose_Of_Visit_Exit" codes, I didn't receive errors, so i figured I was making a step in the right direction. Now for the face-palm moment... What ultimately solved my display problem was setting the Format field in the property box of the table to "Short Time". By the way, thanks for helping me with the time code. I'm still quite a novice at this stuff, and I clearly have much to learn.

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

Similar Threads

  1. Replies: 7
    Last Post: 09-28-2023, 08:41 AM
  2. Replies: 6
    Last Post: 08-01-2013, 12:31 PM
  3. Replies: 15
    Last Post: 12-10-2012, 06:37 PM
  4. Display RESULTS of Query into LISTBOX?
    By taimysho0 in forum Programming
    Replies: 6
    Last Post: 11-22-2011, 10:05 PM
  5. Can't display fields correctly....
    By benjamin in forum Database Design
    Replies: 0
    Last Post: 05-17-2006, 03:43 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