473,770 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
+ 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 "cmdRemoveFilte r"
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 3511
NeoPa
32,573 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,573 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
63588
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 related table depending on the selections of the first. Using the wizard will give me a specific field but will not have a WHERE clause. Is there some code to indicate that the row source is built a variable in the sub set by the first combo box?
2
2100
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 selections in a form and from those selections present them in a report. For example select a selection A,B, and C out of 9 possible choices. Then show them seperated by a comma in a field in the report. I also want the option of only selecting...
0
2473
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 PvdrID, "All" As PvdrDesc FROM tblPrvdr UNION SELECT PvdrID, PvdrDesc FROM tblPrvdr ORDER BY PvdrID; In the query I would place a field which wasn't selected for display which was
2
1499
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 separate selections. I have four individuals that make credits based on 4 separate criteria. Currently, it looks something like this. Ontario - Reg.
2
1576
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 York", only New York cities will show up in the next box. How would I do this?
1
1928
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 Select Box 1
2
4618
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 appears in the text box.
9
3641
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 one, all four, or anything in between. Here is the query, with the "meat" of it sketched out. I'm not sure how to capture the "or any" designation & can't find instructions in any of my SQL references. I've tried everything I can guess at in the Query...
30
2625
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 this and each has been unsuccesful. I will try to explain my database and its contents Tabels and Fields ((PK) indicates the primary Key): tblAssets: ID(PK), AssetNumber, SerialNumber, ModelName, ComputerName, DeploymentDate, Active, UserName,...
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10254
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6710
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.