Default the TIME field in the Manufacturing Automated Collection window

Add the form to VBA, add the field to VBA, then copy in this code. It's fully commented

Private Sub Window_BeforeOpen(OpenVisible As Boolean)
    Dim t As String
    'get the current time
    t = Time()
             
    'get rid of the colons
    t = Replace(t, ":", "")
    'if it's AM, get rid of the AM text
    t = Replace(t, " AM", "")
     
    'PM is more difficult
    If Right(t, 2) = "PM" Then
        'get rid of the PM text
        t = Replace(t, " PM", "")
        'move the time up 12 hours (military style)
        t = t + 120000
    End If
    'for times before 10 AM, this result at this point will be 5 characters
    'add a sixth char
    t = Right("0" + t, 6)
     
    'all set
    Me.ADCTime.Value = t
End Sub

 

 

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences