473,478 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Create reports based on multiple combo box selections

6 New Member
"Form1"
combobox "cboModel"
Row Source
Expand|Select|Wrap|Line Numbers
  1. SELECT [tblModel].[ID], [tblModel].[Model] FROM tblModel ORDER BY [Model]; 
  2.  
combobox "cboContactName"
Expand|Select|Wrap|Line Numbers
  1. SELECT [Query1].[Contact Name] FROM Query1 ORDER BY [Contact Name]; 
  2.  
quick explanation: I have a table named tblCOntacts and in this table i have 3 fields "LastName" and "FirstName" and "Initial" becuase i have multiple employess that have the same last names and sometimes same first and last name. So I have a query titled "Query1" with 2 feilds in it titled:
"File AS" and "Contact Name". Each of these fields combines the first and last name into one field. one does it first name last name and the other last name first name.

and then on form1 i have two cmdbuttons "cmdApplyFilter" and "cmdRemoveFilter"
I have tried two differant codes
Here is the 1st code:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub cmdApplyFilter_Click()
  5.     Dim strModel As String
  6.     Dim strContactName As String
  7.     Dim strFilter As String
  8. ' Check that the report is open
  9.   DoCmd.OpenReport "rptContacts", acPreview, , strFilter
  10. ' Build criteria string for Office field
  11.     If IsNull(Me.cboModel.Value) Then
  12.         strModel = "Like '*'"
  13.     Else
  14.         strModel = "='" & Me.cboModel.Value & "'"
  15.     End If
  16. ' Build criteria string for Department field
  17.     If IsNull(Me.cboContactName.Value) Then
  18.         strContactName = "Like '*'"
  19.     Else
  20.         strContactName = "='" & Me.cboContactName.Value & "'"
  21.     End If
  22. ' Combine criteria strings into a WHERE clause for the filter
  23.     strFilter = "[Model] " & strModel & " AND [ContactName] " & strContactName
  24. ' Apply the filter and switch it on
  25.     With Reports![rptContacts]
  26.         .Filter = strFilter
  27.         .FilterOn = True
  28.     End With
  29. End Sub
  30.  
  31. Private Sub cmdRemoveFilter_Click()
  32.     On Error Resume Next
  33. ' Switch the filter off
  34.     Reports![rptContacts].FilterOn = False
  35. End Sub
  36.  
Using this code i get a.) two small form popups asking for the model value and contactname value then it returns a blank report

Here is the seconf code I tried:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpenReport_Click()
  2.     Dim strModel As String
  3.     Dim strContactName As String
  4.     Dim strFilter As String
  5.     strFilter = "1=1 "
  6. ' Build criteria string for Office field
  7.     If Not IsNull(Me.cboModel) Then
  8.         strFilter  = " AND [Model] ='" & Me.cboModel.Value & "'"
  9.     End If
  10. ' Build criteria string for Department field
  11.     If Not IsNull(Me.cboContactName) Then
  12.         strFilter = " AND [Contact Name] ='" & Me.cboContactName.Value & "'"
  13.     End If
  14. ' Apply the filter and switch it on
  15.   DoCmd.OpenReport "rptContacts", acPreview, , strFilter
  16.  
  17. End Sub
  18.  
For this i get the following error:
Run Time Error '3075':
Syntax error (missing operator) in query expression ' AND [Model]='*620".

Any help please!!
Feb 26 '09 #1
4 3479
NeoPa
32,556 Recognized Expert Moderator MVP
A question would be a good starting point. What do you want to know?
Feb 26 '09 #2
jvan2008
6 New Member
Well lets see the title is "Create reports based on multiple combo box selections". Im going to say, how do I do it? or maybe, why isnt my code working? I thought it was prety obivous
Feb 27 '09 #3
NeoPa
32,556 Recognized Expert Moderator MVP
@jvan2008
I doubt you'll want help from someone who thought it was a rambling mess then.

Good luck.
Feb 27 '09 #4
jvan2008
6 New Member
Well thanks for all your help sport
Feb 27 '09 #5

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

Similar topics

3
63504
by: Richard Hollenbeck | last post by:
I want to have a second combo box have its selection options based on a selection made in a first combo box. The first one gathers data from a table, and the second one should gather data from a...
2
2088
by: Craig B. | last post by:
I am relativly new to access 2000 and am having some trouble with a report. I am not sure what I want to do is something I can do in access. I want to be able to choose from a combo box multiple...
0
2445
by: Greg Strong | last post by:
Hello All, In the past I've used a combo box with the 'row source' being an Access SQL union query to select "All" or 1 for only 1 criteria in a query. An example is as follows: SELECT 0 As...
2
1476
by: David | last post by:
Hi, This is probably really simple but kinda has me stumped. I have taken over a data base and am looking to modify it to make it more user friendly. Currently, I have a Combo box with 4...
2
1561
by: Nick Douglas | last post by:
I have a form with several combo boxes. What I want to do is limit the selections available in each combo box based on the selections in the other. For instance, if the user selects State "New...
1
1891
by: scanreg | last post by:
My form needs to (1) direct to specified URLs based on a combination of form selections and (2) enable/disable form features based on selections within the form FORM Radio 1 - A - B - C ...
2
4590
by: SHAWTY721 | last post by:
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number...
9
3604
WyvsEyeView
by: WyvsEyeView | last post by:
I have a form that has four unbound combo boxes: cboType, cboVersion, cboStatus, cboReview. I want to write a query that basically lets users make selections in as many combo boxes as apply...only...
30
2584
by: vanlanjl | last post by:
Question: How do I create a Report based off the values/selections of mutliple combo boxes in a form? I have tried this several times with several failures and have used multiple codes to try...
0
7027
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
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
6847
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...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4463
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
555
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.