473,394 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Entering Times

PhilOfWalton
1,430 Expert 1GB
Background:
We are running a Half Marathon event, and I want to enter the elapsed times as painlessly as possible. By and large, results come in in order of finishing, so the next person to finish will have a time greater or equal to the previous runner.

I select the runner whose time I want to enter, and let's say the time of the previous runner was 1:23:40
So by default I set the current runner's time the same 1:23:40
Now lets say his actual finishing time is 1:25:21.
What I want to do is just type 521 (no colons) and have that overwriting the 3:40. (3 minutes 40 seconds)

I have a procedure that works to give the correct results, but it fires on the AfterUpdate of the Text Box where I enter the 521. I can give details if relevant. With this routine, entering 1 or 2 numbers alters the seconds; entering 3 or 4 numbers alters minutes and seconds; entering 5 or 6 numbers alters hours minutes and seconds.

Although it works perfectly, the operator can't see what is happening.

What I think I want is to run a procedure on the OnChange of the text box to overlay the numbers. So as each number is entered, the previously entered number must move 1 place to the left, avoiding the colons.

so I envisage something like this:-
Expand|Select|Wrap|Line Numbers
  1. Number Entered     Display
  2.                    01:23:40
  3.        5           01:23:45
  4.        2           01:23:52
  5.        1           01:25:21
  6.  

Any ideas please?

Phil
May 14 '17 #1

✓ answered by NeoPa

Hi Phil.

More details to follow later but the form has a TextBox called [txtTest] and the code below does what you need :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private strLastUsed As String
  5. Private lngLastPos As Long
  6.  
  7. Private Sub Form_Open(Cancel As Integer)
  8.     strLastUsed = "00:00:00"
  9. End Sub
  10.  
  11. Private Sub txtTest_Enter()
  12.     Me.txtTest = Right(strLastUsed, IIf(strLastUsed Like "0*", 7, 8))
  13.     lngLastPos = 0
  14. End Sub
  15.  
  16. Private Sub txtTest_KeyDown(KeyCode As Integer, Shift As Integer)
  17.     If Shift <> 0 Then Exit Sub
  18.     Select Case KeyCode
  19.     Case vbKey0 To vbKey9
  20.         Call ProcessKey(Asc("0") + KeyCode - vbKey0)
  21.         KeyCode = 0
  22.     Case vbKeyNumpad0 To vbKeyNumpad9
  23.         Call ProcessKey(Asc("0") + KeyCode - vbKeyNumpad0)
  24.         KeyCode = 0
  25.     End Select
  26. End Sub
  27.  
  28. Private Sub ProcessKey(intASC As Integer)
  29.     Const conPos As String = "8775544221"
  30.     Dim lngPos As Long, lngFrom As Long, lngTo As Long
  31.  
  32.     For lngPos = lngLastPos To 1 Step -1
  33.         lngFrom = CLng(Mid(conPos, lngPos * 2 - 1, 1))
  34.         lngTo = CLng(Mid(conPos, lngPos * 2, 1))
  35.         Mid(strLastUsed, lngTo, 1) = Mid(strLastUsed, lngFrom, 1)
  36.     Next lngPos
  37.     Mid(strLastUsed, 8, 1) = Chr(intASC)
  38.     Me.txtTest = Right(strLastUsed, IIf(strLastUsed Like "0*", 7, 8))
  39.     lngLastPos = lngLastPos + 1
  40. End Sub

6 1024
zmbd
5,501 Expert Mod 4TB
Just to be clear:
You have an unbound textbox that you're entering the new time in?
May 14 '17 #2
PhilOfWalton
1,430 Expert 1GB
Yes the unbound textbox is InputElapsed1

What happens is on the OnCurrant of the form, I run this

Expand|Select|Wrap|Line Numbers
  1. Sub PartialTime()
  2.  
  3.     'Highlight and attempt to predict time of next finisher
  4.     Dim StartTime As Date
  5.  
  6.     StartTime = Nz(DLookup("StartTime", "TblJoinRaceYear", "RaceID = " & RaceID & " AND YearID = " & DMax("YearID", "TblJoinRaceYear")))
  7.  
  8.     FinishTime.SetFocus
  9.  
  10.     If IsNull(FinishTime) Then
  11.         FTime = Nz(DMax("FinishTime", "QGroupFinishTime", "RaceGroupID = " & CboRaceGroupID))
  12.         If FTime = 0 Then                           ' No finishers for this race so use start time
  13.             FTime = Nz(DLookup("StartTime", "TblJoinRaceYear", "RaceID = " & RaceID & " AND YearID = " & DMax("YearID", "TblJoinRaceYear")))
  14.             FinishTime = FTime
  15.             FinishTime.SetFocus
  16.             FinishTime.SelStart = 0
  17.             FinishTime.SelLength = 8
  18.         Else
  19.             FinishTime = FTime
  20.             FinishTime.SetFocus
  21.             FinishTime.SelStart = 6
  22.             FinishTime.SelLength = 2
  23.         End If
  24.         If Second(FTime) > 57 Then                ' Probably next minute
  25.             FinishTime.SelStart = 3
  26.             FinishTime.SelLength = 5
  27.         End If
  28.     End If
  29.  
  30.     InPutElapsed = CStr(CDate(DateDiff("s", StartTime, FinishTime) / 86400))
  31.     InputElapsed1 = InPutElapsed
  32.  
  33. End Sub
  34.  
So StartTime looks up the starting time of the race.
FinishTime is a bound textbox to enter the finishing time.
FTime finds the maximum finishing time for runners in that group (Half marathon or Fun Run).

As I mentioned, I have one routine that works. The SelStarts and SelLength attempt to position the cursor so that one can enter just seconds or seconds & minutes, but in the latter case you also have to type a colon - real pain.

The unbound Field InputElapsed shows the elapsed time and AfterUpdate Calculates & saves the FinishTime if I chhose to enter the elapsed time rather than the finishing time.

InputElapsed1 (the unbound field mentioned earlier) is the new field I am trying to sort out, and initially displays the same elapsed time as InputElapsed.

So the bit in my first post, where it is marked Display, is what I want to see in InputElapsed1.

Hope that clarifies things

Thanks

Phil
May 14 '17 #3
NeoPa
32,556 Expert Mod 16PB
Hi Phil.

More details to follow later but the form has a TextBox called [txtTest] and the code below does what you need :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private strLastUsed As String
  5. Private lngLastPos As Long
  6.  
  7. Private Sub Form_Open(Cancel As Integer)
  8.     strLastUsed = "00:00:00"
  9. End Sub
  10.  
  11. Private Sub txtTest_Enter()
  12.     Me.txtTest = Right(strLastUsed, IIf(strLastUsed Like "0*", 7, 8))
  13.     lngLastPos = 0
  14. End Sub
  15.  
  16. Private Sub txtTest_KeyDown(KeyCode As Integer, Shift As Integer)
  17.     If Shift <> 0 Then Exit Sub
  18.     Select Case KeyCode
  19.     Case vbKey0 To vbKey9
  20.         Call ProcessKey(Asc("0") + KeyCode - vbKey0)
  21.         KeyCode = 0
  22.     Case vbKeyNumpad0 To vbKeyNumpad9
  23.         Call ProcessKey(Asc("0") + KeyCode - vbKeyNumpad0)
  24.         KeyCode = 0
  25.     End Select
  26. End Sub
  27.  
  28. Private Sub ProcessKey(intASC As Integer)
  29.     Const conPos As String = "8775544221"
  30.     Dim lngPos As Long, lngFrom As Long, lngTo As Long
  31.  
  32.     For lngPos = lngLastPos To 1 Step -1
  33.         lngFrom = CLng(Mid(conPos, lngPos * 2 - 1, 1))
  34.         lngTo = CLng(Mid(conPos, lngPos * 2, 1))
  35.         Mid(strLastUsed, lngTo, 1) = Mid(strLastUsed, lngFrom, 1)
  36.     Next lngPos
  37.     Mid(strLastUsed, 8, 1) = Chr(intASC)
  38.     Me.txtTest = Right(strLastUsed, IIf(strLastUsed Like "0*", 7, 8))
  39.     lngLastPos = lngLastPos + 1
  40. End Sub
May 14 '17 #4
PhilOfWalton
1,430 Expert 1GB
Thanks a lot for that. Took a bit more fiddling, but working perfectly

Again my grateful thanks

Phil
May 15 '17 #5
jforbes
1,107 Expert 1GB
This may be something you are not comfortable with, but when it comes to something like this, especially with the more basic users, I have found it's better to provide the user a Button that displays a centered Dialog Box, and has the Default displayed and editable, and OK and Cancel Buttons. The user can edit the Default to their liking and hit the correct button. This will eliminate all the confusion and the user will really only enter in the same amount of characters. To make it even easier, you could position the cursor at the end of the Default TextBox, then all they have to do is backspace the unwanted numbers out.
May 15 '17 #6
PhilOfWalton
1,430 Expert 1GB
That was my first instinct, and normally I would agree with you, but in this instance, time is of the essence and as Neopa pointed out to me, using both the keyboard and a mouse slows the operation down.
So the latest version is keyboard only, and basically, after updating the record, the cursor moves to the the Combo box where I enter the next competitors's number.

But thanks for the obsevation

Phil
May 15 '17 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Paul | last post by:
Hi This has taken me ages to work out but i'm sure there is a simple explanation and somebody here will be able to help. I'll talk you through it as best i can: 1. User enters dates on an...
17
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched...
12
by: Phoe6 | last post by:
The Program Fragment is this: int choice; /* Users Input Command */ .. .. .. printf("Enter a command: "); fflush(stdin); choice = getc(stdin); printf("\n");
2
by: B Garner | last post by:
Hi all Help please. I would like to automate the printing of a report. The report actually is a single page and prints a label. I would like to be able to print the report multiple times...
0
by: orangekeeper | last post by:
Hi Guys, Sorry, I'm a bit dim here but can anyone advise on the following? I'm looking at writing a VB script from Excel that opens a particular web page, logs in, selects a particular link and...
2
by: robertns5411 | last post by:
I have two questions: 1) Say I have a form bound to a table. Assume the user is entering data into a new record at the bottom of the form. Now, suppose the user clicks a button on the form...
5
by: andi | last post by:
Hello, I created a report in Acess2000 and now it repeats itself three times. At first I thought its a problem with the page margins but that would mean that empty or almost empty pages would...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
2
by: kinglaplace64220 | last post by:
I am supposed to call a function (ERRORCOUNT(BOOL=TRUE) that is supposed to count how many times the user made an invalid error (entering values less than 0 or letters besides "A", "B", "C"). How...
6
by: cqljohn | last post by:
I am new to access, am building a DB for a lab, the DB uses a switchboard that opens full screen to different forms with only options to add a new record. I have different forms for each test and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.