troubleshooting Question

Microsoft Access 2007 - Time Format Help Needed

Avatar of Eileen Murphy
Eileen MurphyFlag for United States of America asked on
Microsoft AccessMicrosoft Development
12 Comments1 Solution680 ViewsLast Modified:
I have used this code for years -- had to modify it for 2007+ but it still works great. Allows users to use a simple time picker to populate time fields.

All date fields in question (in the application and form where the code works as well as this one, the form in question) are "Medium Time"

From a main form I have a clock button next to time fields. If they click on it I send the existing time information to the time selection form where the user can change it. Despite the fact that both the table and the forms fields are formatted as "Medium Time" one form only sends the Hour Portion of the time as military time. I have attached screen shots.

CODE:

Private Sub cmdEndTime_Click()

    DoCmd.OpenForm "fClockPopUp", , , , , , "frmSessions - EndTime"
   
    If IsNull(Me.EndTime) = False Then
        Dim strAmorPm As String
        Forms!fClockPopUp!theTime = Me.EndTime
        Forms!fClockPopUp!cboAMPM = UCase(Format(Me.EndTime, "am/pm"))
        Forms!fClockPopUp!txtHour = Format(Me.EndTime, "hh") <<< line in question
        If Minute(Me.EndTime) < 10 Then
            Forms!fClockPopUp!txtMin = "0" & Minute(Me.EndTime)
        Else
            Forms!fClockPopUp!txtMin = Minute(Me.EndTime)
        End If
    End If

End Sub
ScreenShot.doc
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros