Consulting

Results 1 to 4 of 4

Thread: Solved: Time format in user form

  1. #1

    Solved: Time format in user form

    I have been trying to assign a user form to update cells within a workbook, But am having problems with the time format in tbxTimeswap. It displays the time in this format 03:18:57 PM and I want it in 03:18 PM [VBA]Private Sub cmdSubmit_Click()
    With Sheets(1)
    .Range("B2").Value = tbxEmployeeNum
    tbxEmployeeNum = Empty
    frmDataEntry.Hide
    .Range("A1").Value = tbxLRV1
    tbxLRV1 = Empty
    .Range("A2").Value = tbxLRV2
    tbxLRV2 = Empty
    .Range("A3").Value = tbxLRV3
    tbxLRV3 = Empty
    .Range("B1").Value = tbxRunNum
    tbxRunNum = Empty
    .Range("B4").Value = tbxLoc
    tbxLoc = Empty
    .Range("A1").Value = tbxNewLrv1
    tbxNewLrv1 = Empty
    .Range("A2").Value = tbxNewLrv2
    tbxNewLrv2 = Empty
    .Range("A3").Value = tbxNewLrv3
    tbxNewLrv3 = Empty
    .Range("E8,C4").Value = tbxTimeswap
    Me.tbxTimeswap.Value = Format(Time())
    .Range("C1").Value = tbxTripNum
    tbxTripNum = Empty
    frmDataEntry.Hide



    End With
    End Sub[/VBA]
    Scooter172

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Me.tbxTimeswap.Text= Format(Time(),"hh:mm:ss")
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,872
    xld, did you not mean "hh:mm AM/PM" ?
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4

    Time Format

    Quote Originally Posted by xld
    [vba]

    Me.tbxTimeswap.Text= Format(Time(),"hh:mm:ss")
    [/vba]Private Sub cmdSubmit_Click()
    With Sheets(1)
    .Range("B2").Value = tbxEmployeeNum
    tbxEmployeeNum = Empty
    .Range("A1").Value = tbxLRV1
    tbxLRV1 = Empty
    .Range("A2").Value = tbxLRV2
    tbxLRV2 = Empty
    .Range("A3").Value = tbxLRV3
    tbxLRV3 = Empty
    .Range("B1").Value = tbxRunNum
    tbxRunNum = Empty
    .Range("B4").Value = tbxLoc
    tbxLoc = Empty
    .Range("A1").Value = tbxNewLrv1
    tbxNewLrv1 = Empty
    .Range("A2").Value = tbxNewLrv2
    tbxNewLrv2 = Empty
    .Range("A3").Value = tbxNewLrv3
    tbxNewLrv3 = Empty
    .Range("E8").Value = tbxTimeswap
    Me.tbxTimeswap.Value = Format(Time(), "hh:mm am/pm")
    .Range("C1").Value = tbxTripNum
    tbxTripNum = Empty
    frmDataEntry.Hide



    End With
    End Sub
    Here is what I came up with... Brain Cramp I guess!
    Scooter172

Posting Permissions

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