Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / February 2007

Tip: Looking for answers? Try searching our database.

limiting input on time formatted control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 28 Feb 2007 19:41 GMT
I may not have said that correctly.  Here goes...

User inputs time into a field by entering or using KeyPress event to
increase/decrease time in 15 minute increments.
******* code for keypress event
Dim strInterval As String
strInterval = "n"
Select Case KeyAscii
   Case 43   'plus key
       KeyAscii = 0
       Screen.ActiveControl = DateAdd(strInterval, 15, Screen.ActiveControl)
   Case 45   'minus key
       KeyAscii = 0
       Screen.ActiveControl = DateAdd(strInterval, -15, Screen.ActiveControl)
End Select
******* end code

My conrtrol [txtDC7Start] is formatted "h:nn a/p" and defaults to "8:00 a".
Its control source is [DC7Start].  Presently, the user can +/- or enter the
time.  I want to restrict their input to between 6 am and 10 pm.  I am having
trouble with the time format combined with limitation.  

Can someone suggest a simple method to accomplish this limitation?  The

Signature

Thanks for your help,
Chris

John W. Vinson - 28 Feb 2007 21:12 GMT
>I may not have said that correctly.  Here goes...
>
[quoted text clipped - 19 lines]
>
>Can someone suggest a simple method to accomplish this limitation?  The

The format shouldn't have anything to do with it. If you want to
constrain the result to a range of times, what do you want to happen
when the user gets outside the range?

Try this:

Dim strInterval As String
Dim vTime As Variant
vTime = Timevalue(Screen.ActiveControl)
strInterval = "n"
Select Case KeyAscii
   Case 43   'plus key
       KeyAscii = 0
       If vTime >= #10:00pm# Then
    Beep
       Else
           vTime = DateAdd(strInterval, 15,vTime)
       End If
   Case 45   'minus key
       KeyAscii = 0
       If vTime <= #6:00am# Then
    Beep
       Else
            vTime = DateAdd(strInterval, -15, vTime)
       End If
End Select
Screen.ActiveControl = vTime

            John W. Vinson [MVP]
Chris - 28 Feb 2007 21:51 GMT
Hmmm...what did I want?  What you gave me. Perfecto!

Once again, the gurus come through for the riff raff.

Thanks, John.
Signature

Chris

> >I may not have said that correctly.  Here goes...
> >
[quoted text clipped - 49 lines]
>
>              John W. Vinson [MVP]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.