Garren.Shannon
Member
- Local time
- Today, 08:30
- Joined
- Sep 22, 2022
- Messages
- 113
Hey all,
I am beta-testing my bus ridership DB and can see that a touch screen tablet keyboard is not very efficient to enter numbers for things like head-count or odometer entry. I added a 10 key keypad that works but needs some expert eyes.
The driver adds the head-count for the trip based on 4 types and the Max count is added up as they go. If you type the numbers in with a keyboard and hit tab, the Max Count adds just fine.
The problem I am having is when the keypad, it enters the number to the box but when I tab away, it does not add the entered number to Max-Count. Here's the code for the form I am working on. I am still playing with the tab left and right using sendkey but I don't think that is a great way to do it. Also, not sure if I should add a backup for the driver if they enter a bad number and want to delete it.
I am beta-testing my bus ridership DB and can see that a touch screen tablet keyboard is not very efficient to enter numbers for things like head-count or odometer entry. I added a 10 key keypad that works but needs some expert eyes.
The driver adds the head-count for the trip based on 4 types and the Max count is added up as they go. If you type the numbers in with a keyboard and hit tab, the Max Count adds just fine.
The problem I am having is when the keypad, it enters the number to the box but when I tab away, it does not add the entered number to Max-Count. Here's the code for the form I am working on. I am still playing with the tab left and right using sendkey but I don't think that is a great way to do it. Also, not sure if I should add a backup for the driver if they enter a bad number and want to delete it.
Code:
Option Compare Database
Option Explicit
Private Function FillTextBox(intX As Integer)
Debug.Print strTextBox
Select Case strTextBox
Case "BasicCount":
If Me.BasicCount = 0 Then
Me.BasicCount = intX
Else
Me.BasicCount = Me.BasicCount & intX
End If
Case "SpedCount":
If Me.SpedCount = 0 Then
Me.SpedCount = intX
Else
Me.SpedCount = Me.SpedCount & intX
End If
Case "HSCount":
If Me.HSCount = 0 Then
Me.HSCount = intX
Else
Me.HSCount = Me.HSCount & intX
End If
Case "WalkCount":
If Me.WalkCount = 0 Then
Me.WalkCount = intX
Else
Me.WalkCount = Me.WalkCount & intX
End If
Case "MaxCount":
If Me.MaxCount = 0 Then
Me.MaxCount = intX
Else
Me.MaxCount = Me.MaxCount & intX
End If
End Select
End Function
Private Sub BasicCount_GotFocus()
strTextBox = "BasicCount"
End Sub
Private Sub cmdBackTab_Click()
SendKeys "+{TAB}", False
End Sub
Private Sub cmdTab_Click()
SendKeys "{TAB}", False
End Sub
Private Sub SpedCount_GotFocus()
strTextBox = "SpedCount"
End Sub
Private Sub HSCount_GotFocus()
strTextBox = "HSCount"
End Sub
Private Sub WalkCount_GotFocus()
strTextBox = "WalkCount"
End Sub
Private Sub MaxCount_GotFocus()
strTextBox = "MaxCount"
End Sub
Private Sub cmdNine_Click()
Call FillTextBox(9)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdEight_Click()
Call FillTextBox(8)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdSeven_Click()
Call FillTextBox(7)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdSix_Click()
Call FillTextBox(6)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdFive_Click()
Call FillTextBox(5)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdFour_Click()
Call FillTextBox(4)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdThree_Click()
Call FillTextBox(3)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdTwo_Click()
Call FillTextBox(2)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdOne_Click()
Call FillTextBox(1)
Me(strTextBox).SetFocus
End Sub
Private Sub cmdZero_Click()
Call FillTextBox(0)
Me(strTextBox).SetFocus
End Sub
Private Sub NextBtn_Click()
vCount_BA = Me.BasicCount
vCount_SP = Me.SpedCount
vCount_HS = Me.HSCount
vCount_WA = Me.WalkCount
vCount_MAX = Me.MaxCount
vDescription = Nz(Me.Desc, " ")
vRetTime = Time()
DoCmd.OpenForm "Frm_3_StartTrip", acNormal
Me.Move 0, 0
DoCmd.Close acForm, "Frm_2_StartTrip", acSaveNo
Forms("Frm_3_StartTrip").SetFocus
End Sub
Private Sub Form_Load()
Dim strTextBox As String
Me.TripDateLb.Caption = Format(vTripDate, "Short Date")
Me.StartTimeLb.Caption = vDeptTime
Me.InitLB.Caption = vDriverInitials
Me.VehicleLb.Caption = Nz(DLookup("VehicleName", "vehicles", "VehicleUniqID =" & vCurrentVehicle), "Bus 10")
If vID_Code = 1 Then
Me.TripType.Caption = "Trip Type: To/From"
ElseIf vID_Code = 2 Then
Me.TripType.Caption = "Trip Type: Fld Trip"
ElseIf vID_Code = 3 Then
Me.TripType.Caption = "Trip Type: Act"
Else
Me.TripType.Caption = "Trip Type: Misc"
End If
If vInsp_Pre = True Then
Me.Pre_InspLB.Caption = "Pre-Insp: Completed."
Else
Me.Pre_InspLB.Caption = "Pre-Insp: NOT Completed."
End If
Me.StartODLb.Caption = "Starting OD: " + Str(vDeptOD)
Me.BasicCount = vCount_BA
Me.SpedCount = vCount_SP
Me.HSCount = vCount_HS
Me.WalkCount = vCount_WA
Me.MaxCount = vCount_MAX
Me.Desc = vDescription
End Sub
Private Sub Quit_Click()
Dim answer As Integer
answer = MsgBox("Are you sure you want to quit?", vbQuestion + vbYesNo + vbDefaultButton2, "Quit???")
If answer = vbYes Then
Call ResetTripVars
DoCmd.OpenForm "Frm_MainMenu", acNormal
Me.Move 0, 0
DoCmd.Close acForm, "Frm_2_StartTrip", acSaveNo
Forms("Frm_MainMenu").SetFocus
End If
End Sub
Private Sub BasicCount_Change()
If IsNumeric(Me.BasicCount) = False Or Me.BasicCount < 0 Then
Me.BasicCount = 0
MsgBox ("This must be a positive number")
Me.MaxCount.SetFocus
Me.BasicCount.SetFocus
Else
Me.MaxCount = Me.MaxCount + Me.BasicCount
End If
End Sub
Private Sub HSCount_Change()
If IsNumeric(Me.HSCount) = False Or Me.HSCount < 0 Then
Me.HSCount.Value = 0
MsgBox ("This must be a positive number")
Me.MaxCount.SetFocus
Me.HSCount.SetFocus
Else
Me.MaxCount = Me.MaxCount + Me.HSCount
End If
End Sub
Private Sub SpedCount_Change()
If IsNumeric(Me.SpedCount) = False Or Me.SpedCount < 0 Then
Me.SpedCount = 0
MsgBox ("This must be a positive number")
Me.MaxCount.SetFocus
Me.SpedCount.SetFocus
Else
Me.MaxCount = Me.MaxCount + Me.SpedCount
End If
End Sub
Private Sub WalkCount_Change()
If IsNumeric(Me.WalkCount) = False Or Me.WalkCount < 0 Then
Me.WalkCount = 0
MsgBox ("This must be a positive number")
Me.MaxCount.SetFocus
Me.WalkCount.SetFocus
End If
End Sub
Private Sub MaxCount_Change()
If IsNumeric(Me.MaxCount) = False Or Me.MaxCount < 0 Then
Me.MaxCount = 0
MsgBox ("This must be a positive number")
Me.BasicCount.SetFocus
Me.MaxCount.SetFocus
End If
End Sub