I have a form that has two (2) calendar dates 1. fromdatetext, 2. todatetext. I would like to be able to search the records from query "Emp_Lst_Frm_Qu ery" and give the sum results from the dates. I would like to use the "Sub_Cmd" button to activate the search. I will be commenting out the case statement so the button only does the search for the dates.
I would like to be able to put total records in TotalTxt and then populate Incident, Request, and ChangeOrder fields with the proper sums.
The calendar controls work perfect.
Here is the code for the entire form, I am currently doing things one piece at a time. Then when things are working the way I like, I then combine them.
I would like to thank everyone in advance because this site has been a great resource.
I would like to be able to put total records in TotalTxt and then populate Incident, Request, and ChangeOrder fields with the proper sums.
The calendar controls work perfect.
Here is the code for the entire form, I am currently doing things one piece at a time. Then when things are working the way I like, I then combine them.
Code:
Option Compare Database
Dim Originatorcmb As ComboBox
Private Sub ocxcalendar_Click()
Originatorcmb.Value = ocxcalendar.Value
Originatorcmb.SetFocus
ocxcalendar.Visible = False
Set Originatorcmb = Nothing
End Sub
Private Sub fromdatecmb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set Originatorcmb = fromdatecmb
ocxcalendar.Visible = True
ocxcalendar.SetFocus
If Not IsNull(Originatorcmb) Then
ocxcalendar.Value = Originatorcmb.Value
Else
ocxcalendar.Value = Date
End If
End Sub
Private Sub todatecmb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set Originatorcmb = todatecmb
ocxcalendar.Visible = True
ocxcalendar.SetFocus
If Not IsNull(Originatorcmb) Then
ocxcalendar.Value = Originatorcmb.Value
Else
ocxcalendar.Value = Date
End If
End Sub
Private Sub Sub_Cmd_Click()
Dim typeCount As Integer
Select Case typeCount = DCount("[workedby]", "Emp_Lst_Frm_Query", "[workedby]= '" & Me.empcmb.Value & "'")
Case Me.empcmb.Value = "1"
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[workedby] = 'MJA'")
Me.TotalTxt.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Incident' And [workedby] = 'MJA'")
Me.Inc_Text.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Request' and [workedby] = 'MJA'")
Me.Req_Text.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Change Order' and [workedby]= 'MJA'")
Me.CO_Text.Value = typeCount
Me.Repaint
Case Me.empcmb.Value = "2"
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[workedby] = 'MOB'")
Me.TotalTxt.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Incident' And [workedby] = 'MOB'")
Me.Inc_Text.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Request' and [workedby] = 'MOB'")
Me.Req_Text.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Change Order' and [workedby]= 'MOB'")
Me.CO_Text.Value = typeCount
Me.Repaint
Case Else
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[workedby] = 'SLT'")
Me.TotalTxt.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Incident' And [workedby] = 'SLT'")
Me.Inc_Text.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Request' and [workedby] = 'SLT'")
Me.Req_Text.Value = typeCount
Me.Repaint
typeCount = DCount("[type]", "Emp_Lst_Frm_Query", "[Type] = 'Change Order' and [workedby]= 'SLT'")
Me.CO_Text.Value = typeCount
Me.Repaint
End Select
End Sub
Comment