Calculations for calculating calories burned and speed
Private Sub cmbActivities_BeforeUpdate(Cancel As Integer)
Me.cmbSwimming.Visible = False
Me.txtDistance.Visible = True
Me.txtSpeed.Visible = True
If Me.cmbActivities = "Running" Then
Me.cmbSwimming.Visible = False
Me.txtDistance.Visible = True
Me.txtSpeed.Visible = True
ElseIf Me.cmbActivities = "Cycling" Then
Me.cmbSwimming.Visible = False
Me.txtDistance.Visible = True
Me.txtSpeed.Visible = True
ElseIf Me.cmbActivities = "Swimming" Then
Me.txtDistance.Visible = False
Me.txtSpeed.Visible = False
Me.cmbSwimming.Visible = True
End If
Private Sub cmdNew_Click()
Private Sub txtDate_BeforeUpdate(Cancel As Integer)
If Me.txtDate = "" Or IsNull(Me.txtDate) Then
MsgBox ("Please enter date.")
Cancel = True 'force the cursor to remain inside the textbox
End If
Private Sub txtDistance_BeforeUpdate(Cancel As Integer)
If Me.txtDistance = "" Or IsNull(Me.txtDistance) And (Me.cmbActivities = "Running" Or Me.cmbActivities = "Cycling") Then
MsgBox ("Please enter distance.")
Cancel = True 'force the cursor to remain inside the textbox
End If
If Me.txtDistance <= 0 And (Me.cmbActivities = "Running" Or Me.cmbActivities = "Cycling") Then
MsgBox ("Please enter valid distance.")
Cancel = True 'force the cursor to remain inside the textbox
End If
Private Sub txtFinishingTime_BeforeUpdate(Cancel As Integer)
If Me.txtFinishingTime = "" Or IsNull(Me.txtFinishingTime) Then
MsgBox ("Please enter finishing time.")
Cancel = True 'force the cursor to remain inside the textbox
End If
If Me.txtFinishingTime <= 0 Or Me.txtFinishingTime <= Me.txtStartTime Then
MsgBox ("Please enter valid finishing time.")
Cancel = True 'force the cursor to remain inside the textbox
End If
Private Sub txtStartTime_BeforeUpdate(Cancel As Integer)
If Me.txtStartTime = "" Or IsNull(Me.txtStartTime) Then
MsgBox ("Please enter start time.")
Cancel = True 'force the cursor to remain inside the textbox
End If
If Me.txtStartTime <= 0 Then
MsgBox ("Please enter valid start time.")
Cancel = True 'force the cursor to remain inside the textbox
End If
Private Sub txtWeight_BeforeUpdate(Cancel As Integer)
If Me.txtWeight = "" Or IsNull(Me.txtWeight) Then
MsgBox ("Please enter weight.")
Cancel = True 'force the cursor to remain inside the textbox
End If
If Me.txtWeight <= 0 Then
MsgBox ("Please enter valid weight.")
Cancel = True 'force the cursor to remain inside the textbox
End If
Private Sub cmdMenu_Click()
DoCmd.OpenForm ("frmMenu")
Private Sub cmdSubmit_Click()
Me.txtActivityTime = Me.txtFinishingTime - Me.txtStartTime
If Me.cmbActivities = "" Or IsNull(Me.cmbActivities) Then
MsgBox ("Please fill in missing forms.")
Exit Sub ' exit subroutine
End If
If Me.txtDate = "" Or IsNull(Me.txtDate) Then
MsgBox ("Please fill in missing forms.")
Exit Sub ' exit subroutine
End If
If Me.txtStartTime = "" Or IsNull(Me.txtStartTime) Then
MsgBox ("Please fill in missing forms.")
Exit Sub ' exit subroutine
End If
If Me.txtFinishingTime = "" Or IsNull(Me.txtFinishingTime) Then
MsgBox ("Please fill in missing forms.")
Exit Sub ' exit subroutine
End If
If Me.txtDistance = "" Or IsNull(Me.txtDistance) And (Me.cmbActivities = "Running" Or Me.cmbActivities = "Cycling") Then
MsgBox ("Please fill in missing forms.")
Exit Sub ' exit subroutine
End If
If Me.txtWeight = "" Or IsNull(Me.txtWeight) Then
MsgBox ("Please fill in missing forms.")
Exit Sub ' exit subroutine
End If
If Me.cmbActivities = "Running" Then
Me.txtSpeed = Me.txtDistance / Me.txtActivityTime
Me.txtCaloriesBurned = 472 / 5 * Me.txtSpeed
Me.txtCaloriesBurned = Me.txtCaloriesBurned / 80 * Me.txtWeight
End If
If Me.cmbActivities = "Cycling" Then
Me.txtSpeed = Me.txtDistance / Me.txtActivityTime
Me.txtCaloriesBurned = 354 / 11 * Me.txtSpeed
Me.txtCaloriesBurned = Me.txtCaloriesBurned / 80 * Me.txtWeight
End If
If Me.cmbActivities = "Swimming" And Me.cmbSwimming = "Backstroke" Then
Me.txtCaloriesBurned = 413 / Me.txtActivityTime
Me.txtCaloriesBurned = Me.txtCaloriesBurned / 80 * Me.txtWeight
ElseIf Me.cmbActivities = "Swimming" And Me.cmbSwimming = "Breaststroke" Then
Me.txtCaloriesBurned = 590 / Me.txtActivityTime
Me.txtCaloriesBurned = Me.txtCaloriesBurned / 80 * Me.txtWeight
ElseIf Me.cmbActivities = "Swimming" And Me.cmbSwimming = "Butterfly" Then
Me.txtCaloriesBurned = 649 / Me.txtActivityTime
Me.txtCaloriesBurned = Me.txtCaloriesBurned / 80 * Me.txtWeight
ElseIf Me.cmbActivities = "Swimming" And Me.cmbSwimming = "Freestyle, slow" Then
Me.txtCaloriesBurned = 590 / Me.txtActivityTime
Me.txtCaloriesBurned = Me.txtCaloriesBurned / 80 * Me.txtWeight
ElseIf Me.cmbActivities = "Swimming" And Me.cmbSwimming = "Freestyle, fast" Then
Me.txtCaloriesBurned = 413 / Me.txtActivityTime
Me.txtCaloriesBurned = Me.txtCaloriesBurned / 80 * Me.txtWeight