473,385 Members | 1,311 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,385 software developers and data experts.

3 List Boxes + Several Check Boxes on a Parameter Form

Hi there, am wondering if someone can tell me how to get 3 list boxes to work in conjunction with a bunch of check-boxes on an independent form and have the results filter the report accordingly.

I have temp tables for each set of code that would pertain to EMPLOYEE / DEPARTMENT / LOCATION. When I run the code when everything is not commented out, the selections that I make go into the temp tables perfectly, but for some reason the temp table results do not get passed onto the report as it should. Therefore, when I press run, the report will display more results than what I specify on the paramter form.

I sure hope someone can help me out with this.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub BTN_RUN_REPORT_Click()
  3. On Error GoTo BTN_RUN_REPORT_Click_Err
  4.  
  5.  
  6.     Dim rs As New ADODB.Recordset
  7.     Dim cnn As New ADODB.Connection
  8.     Dim strSQL As String
  9.  
  10.     DoCmd.SetWarnings False
  11.     DoCmd.RunSQL "DELETE TEMP_TABLE.* FROM TEMP_TABLE;"
  12.     DoCmd.SetWarnings True
  13.  
  14.     Set cnn = CurrentProject.Connection
  15.     strSQL = "SELECT * From TEMP_TABLE"
  16.  
  17.     rs.Open strSQL, cnn, adOpenDynamic, adLockOptimistic
  18.  
  19.       'Ensure that primary key is the bound value of the listbox
  20.       Dim VarItem As Variant
  21.       Dim VarData As Variant
  22.         For Each VarItem In Me.LIST_EMPLOYEE.ItemsSelected
  23.             VarData = Me.LIST_EMPLOYEE.ItemData(VarItem)
  24.  
  25.             rs.AddNew
  26.             rs.Fields("NUID") = VarData
  27.             rs.Update
  28.         Next VarItem
  29.  
  30. ' -------------------------------------------------------------------------------
  31.  
  32. '    Dim rs_2 As New ADODB.Recordset
  33. '    Dim cnn_2 As New ADODB.Connection
  34. '    Dim strSQL_2 As String
  35. '
  36. '    DoCmd.SetWarnings False
  37. '    DoCmd.RunSQL "DELETE TEMP_TABLE_DEPT.* FROM TEMP_TABLE_DEPT;"
  38. '    DoCmd.SetWarnings True
  39. '
  40. '    Set cnn_2 = CurrentProject.Connection
  41. '    strSQL_2 = "SELECT * From TEMP_TABLE_DEPT"
  42. '
  43. '    rs_2.Open strSQL_2, cnn, adOpenDynamic, adLockOptimistic
  44. '
  45. '      'Ensure that primary key is the bound value of the listbox
  46. '      Dim VarItem_2 As Variant
  47. '      Dim VarData_2 As Variant
  48. '        For Each VarItem_2 In Me.LIST_DEPARTMENTS.ItemsSelected
  49. '            VarData_2 = Me.LIST_DEPARTMENTS.ItemData(VarItem_2)
  50. '
  51. '            rs_2.AddNew
  52. '            rs_2.Fields("DEPT_ABBR") = VarData_2
  53. '            rs_2.Update
  54. '        Next VarItem_2
  55.  
  56. ' -------------------------------------------------------------------------------
  57.  
  58. 'Dim rs_3 As New ADODB.Recordset
  59. '    Dim cnn_3 As New ADODB.Connection
  60. '    Dim strSQL_3 As String
  61. '
  62. '    DoCmd.SetWarnings False
  63. '    DoCmd.RunSQL "DELETE TEMP_TABLE_LOCATION.* FROM TEMP_TABLE_LOCATION;"
  64. '    DoCmd.SetWarnings True
  65. '
  66. '    Set cnn_3 = CurrentProject.Connection
  67. '    strSQL_3 = "SELECT * From TEMP_TABLE_LOCATION"
  68. '
  69. '    rs_3.Open strSQL_3, cnn_3, adOpenDynamic, adLockOptimistic
  70. '
  71. '      'Ensure that primary key is the bound value of the listbox
  72. '      Dim VarItem_3 As Variant
  73. '      Dim VarData_3 As Variant
  74. '        For Each VarItem_3 In Me.LIST_MOB.ItemsSelected
  75. '            VarData_3 = Me.LIST_MOB.ItemData(VarItem_3)
  76. '
  77. '            rs_3.AddNew
  78. '            rs_3.Fields("MOB") = VarData_3
  79. '            rs_3.Update
  80. '        Next VarItem_3
  81.  
  82.  
  83. ' -------------------------------------------------------------------------------
  84.  
  85. If (CB_ACUITY_DEPT) Then
  86.   ' Acuity - By Department
  87.   DoCmd.OpenReport "R_ACUITIES_DEPT", acViewPreview, "", "", acWindowNormal
  88.   End If
  89. If (CB_ACUITY_EMPLOYEE) Then
  90.   ' Acuity - By Employee
  91.   DoCmd.OpenReport "R_ACUITIES_EMPLOYEE", acViewPreview, "", "", acWindowNormal
  92.   End If
  93. If (CB_ACUITY_AGE_GROUP) Then
  94.   ' Acuity - By Age Group
  95.   DoCmd.OpenReport "R_ACUITIES_AGE_GROUP", acViewPreview, "", "", acWindowNormal
  96.   End If
  97. If (CB_INTERVENTION_SUMMARY) Then
  98.   ' Intervention Summary - Count
  99.   DoCmd.OpenReport "R_COUNT_INTERVENTION_2", acViewPreview, "", "", acWindowNormal
  100.   End If
  101. If (CB_PROBLEM_SUMMARY) Then
  102.   DoCmd.OpenReport "R_COUNT_PROBLEM_2", acViewPreview, "", "", acWindowNormal
  103.   End If
  104. If (CB_CHILD_ABUSE) Then
  105.   DoCmd.OpenReport "R_CHILD_ABUSE", acViewPreview, "", "", acWindowNormal
  106.   End If
  107. If (CB_ELDER_ABUSE) Then
  108.   DoCmd.OpenReport "R_ELDER_ABUSE", acViewPreview, "", "", acWindowNormal
  109.   End If
  110. If (CB_HOMELESS) Then
  111.   DoCmd.OpenReport "R_HOMELESS", acViewPreview, "", "", acWindowNormal
  112.   End If
  113. If (CB_DOMESTIC_VIOLENCE) Then
  114.   DoCmd.OpenReport "R_DOMESTIC_VIOLENCE", acViewPreview, "", "", acWindowNormal
  115.   End If
  116. If (CB_PSYCH) Then
  117.   DoCmd.OpenReport "R_PSYCH", acViewPreview, "", "", acWindowNormal
  118.   End If
  119. If (CB_ENCTRS_TYPE_LOC) Then
  120.   DoCmd.OpenReport "R_ENCOUNTERS_MOB", acViewPreview, "", "", acWindowNormal
  121.   End If
  122. If (CB_LOC_SUMM_DEPT_EMPL) Then
  123.   DoCmd.OpenReport "R_LOCATION_EMPL1", acViewPreview, "", "", acWindowNormal
  124.   End If
  125. If (CB_LOC_SUMM_DEPT_ENCTR) Then
  126.   DoCmd.OpenReport "R_LOCATION_BY_DEPT", acViewPreview, "", "", acWindowNormal
  127.   End If
  128. If (CB_LOC_SUMM_INTERVENTION) Then
  129.   DoCmd.OpenReport "R_INTERVENTION_2", acViewPreview, "", "", acWindowNormal
  130.   End If
  131. If (CB_LOC_SUMM_PROBLEM) Then
  132.   DoCmd.OpenReport "R_PROBLEM_TYPE_SUMMARY", acViewPreview, "", "", acWindowNormal
  133.   End If
  134. If (CB_PATIENT_AGE_GROUP) Then
  135.   DoCmd.OpenReport "R_PATIENT", acViewPreview, "", "", acWindowNormal
  136.   End If
  137. If (CB_PATIENT_ENCTRS) Then
  138.   DoCmd.OpenReport "R_PATIENT_ENCOUNTERS", acViewPreview, "", "", acWindowNormal
  139.   End If
  140. If (CB_EMPL_PRODUCTIVITY) Then
  141.   DoCmd.OpenReport "R_HOURS_EMPLOYEE", acViewPreview, "", "", acWindowNormal
  142.   End If
  143. If (CB_ENCTR_TYPE_EMPLOYEE) Then
  144.  DoCmd.OpenReport "R_ENCOUNTERS_EMPLOYEE", acViewPreview, "", "", acWindowNormal
  145.  End If
  146.  
  147. BTN_RUN_REPORT_Click_Exit:
  148. Exit Sub
  149.  
  150. BTN_RUN_REPORT_Click_Err:
  151. MsgBox Error$
  152. Resume BTN_RUN_REPORT_Click_Exit
  153.  
  154. End Sub
  155.  
  156.  
Thank you VERY, VERY MUCH for your time and assistance.
Aug 24 '10 #1
0 1020

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

Similar topics

13
by: Adrian Parker | last post by:
I have a PHP generated page which displays X many records. Each record has a checkbox preceding it. The user checks several checkboxes, and hits a delete button. All the corresponding records...
8
by: pw | last post by:
Hi, I need to create a function in javascript to check or uncheck all checkboxes in a form. From what I understand, I can do this either by specifying the name of the check box fields such as: ...
2
by: Ben | last post by:
My current project requires me to create part of a form that is created on the fly. The project consists a list of entries to an event. The name and address and such is easy. The design is detup so...
0
by: Robert | last post by:
Stephen, I think I figured out the problem. I was able to get Check Boxes and Option Buttons to work on my form by TURNING OFF RECORD SELECTORS on the form. Not sure why this would make a...
3
by: Shannan Casteel via AccessMonster.com | last post by:
I have three main tables. The first is the table that my main form will be based on. This is where the user will enter all the data. The table is called TechnicalProblemsTable. It looks like...
5
by: Shreekant Patel | last post by:
Hello, I am new to the advanced level of access, and I have quite a few changes to make to an existing database. The current database's main form needs to have additional check boxes added to...
71
ChaseCox
by: ChaseCox | last post by:
I would like to use a Check Box, or several check boxes, that will allow a user to select differnent product lines. The user should be able to select one or many. I also need each check box to...
2
by: patio | last post by:
MS Access 2007 Form. I need to create either check boxes or a mutivalued list in a form where the user can select more than one item. For example, I am creating a call list that tracks various...
15
by: martin DH | last post by:
Good morning, I have added several posts out here on a project on which I am working - thank you very much to everyone who has responded with ideas and solutions! My new question: I am drawing...
7
by: gerryis2000 | last post by:
i have a list box called Items which i want the user to selct items from. how can i make the selection by ticking check boxes rather than pressing ctrl key and the mouse. thank you
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.