473,402 Members | 2,072 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,402 software developers and data experts.

How do I code the multiple form's function to suit these needs?

Hi all

I have a table containing [Timestamp], [AgentName], [SNOCAcknowledged], [Details], [EventType].

I need to create a multiple item form that counts the records based on event type and displays it like in the image.



The form will be able to even count the number of event types by a date range and/or if it was acknowledged or not.

As you can see in the image, I have successfully managed to do the basic stuff for this. However, my problem lies with the acknowledgement.

When I leave the date range blank and select an acknowledgement to search, the data does not change at all.

My current codes are:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command8_Click()
  2.     Dim Task As String
  3.  
  4.     If Trim(txtStartDate & "") = vbNullString And Trim(txtEndDate & "") = vbNullString Then
  5.         Task = "SELECT EventType, Count(EventType) As CountOfEventType FROM Final GROUP BY EventType;"
  6.  
  7.     ElseIf InStr(Me.Combo9, "Yes") And Trim(txtStartDate & "") = vbNullString And Trim(txtEndDate & "") = vbNullString Then
  8.     Task = " SELECT EventType, Count(EventType) As CountOfEventType " & _
  9.            " FROM Final " & _
  10.            " WHERE Final.SNOCAcknowledged='Yes' " & _
  11.            " GROUP BY EventType;"
  12.  
  13.     ElseIf InStr(Me.Combo9, "No") And Trim(txtStartDate & "") = vbNullString And Trim(txtEndDate & "") = vbNullString Then
  14.     Task = " SELECT EventType, Count(EventType) As CountOfEventType " & _
  15.            " FROM Final " & _
  16.            " WHERE Final.SNOCAcknowledged='No' " & _
  17.            " GROUP BY EventType;"
  18.  
  19.     ElseIf Trim(Me.Combo9 & "") = vbNullString Then
  20.     Task = " SELECT EventType, Count(EventType) As CountOfEventType " & _
  21.            " FROM Final " & _
  22.            " WHERE Final.Timestamp BETWEEN #" & Format(Me.txtStartDate, "MM/DD/YYYY HH:MM:SS AM/PM") & "# " & _
  23.                                      " AND #" & Format(Me.txtEndDate, "MM/DD/YYYY HH:MM:SS AM/PM") & "# " & _
  24.                                      " GROUP BY EventType;"
  25.  
  26.     ElseIf InStr(Me.Combo9, "Yes") Then
  27.     Task = " SELECT EventType, Count(EventType) As CountOfEventType " & _
  28.            " FROM Final " & _
  29.            " WHERE Final.SNOCAcknowledged='Yes' AND Final.Timestamp BETWEEN #" & Format(Me.txtStartDate, "MM/DD/YYYY HH:MM:SS AM/PM") & "# " & _
  30.                                      " AND #" & Format(Me.txtEndDate, "MM/DD/YYYY HH:MM:SS AM/PM") & "# " & _
  31.                                      " GROUP BY EventType;"
  32.  
  33.     ElseIf InStr(Me.Combo9, "No") Then
  34.     Task = " SELECT EventType, Count(EventType) As CountOfEventType " & _
  35.            " FROM Final " & _
  36.            " WHERE Final.SNOCAcknowledged='No' AND Final.Timestamp BETWEEN #" & Format(Me.txtStartDate, "MM/DD/YYYY HH:MM:SS AM/PM") & "# " & _
  37.                                      " AND #" & Format(Me.txtEndDate, "MM/DD/YYYY HH:MM:SS AM/PM") & "# " & _
  38.                                      " GROUP BY EventType;"
  39.  
  40.     End If
  41.     Me.RecordSource = Task
  42. End Sub
  43.  
PS, my dropdown list was actually created using the wizard and filling in my own "yes" and "no", so I don't think changing the thing to true or false helps.
Attached Images
File Type: jpg Capture.jpg (23.6 KB, 221 views)
Dec 5 '14 #1
1 870
I managed to solve it already. I used the debug print to check my Task and it turns out that it was executing the first if statement as the date range was blank.
Dec 5 '14 #2

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

Similar topics

2
by: yoelgold | last post by:
Hi I want to start writing a new site. It will include 3 forms that will collect information from the user. I know how to keep the info in sessions etc. my question is about the design of the...
2
by: belzibob | last post by:
I have inherited a table where each row is a <form> Each of these rows has only four columns, those being: 1) Item number 4) Quantity (blank textbox to fill in) 3) Description 4) Add link (to...
1
by: Don | last post by:
hi in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now i'm using vb.net (still getting used to it)...
10
by: SHPsalm139 | last post by:
We have an Access 2K application that uses multiple forms. We currently hardcode the release number in a label on each form but this gets tedious to do each time there's a new release. I thought...
0
by: question | last post by:
Hi! I have a requirement where I need to display multiple forms one after the other like a slide show. These are in the same application. Basicall on selection of a menu item it should start...
5
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
2
by: yxktmp | last post by:
Hi; I have a main starting query for most of my reporting. I branch out from this query to other queries. This main query contains multiple form control filters (query criterias) . I want to use...
9
by: WanamakerMedia | last post by:
I've posted this in at least 6 other forums with no responses. I am completely new to AJAX, so I got this code from another site and installed it for what I need. It works great if I have only one...
3
by: ryaanmichael | last post by:
I have a function in my database that I want to use in multiple forms. How can I set up my function so that I can just call it in each form? And how do I call it in my form code? For example,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.