"Form1"
combobox "cboModel"
Row Source -
SELECT [tblModel].[ID], [tblModel].[Model] FROM tblModel ORDER BY [Model];
-
combobox "cboContactName " -
SELECT [Query1].[Contact Name] FROM Query1 ORDER BY [Contact Name];
-
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: -
Option Compare Database
-
Option Explicit
-
-
Private Sub cmdApplyFilter_Click()
-
Dim strModel As String
-
Dim strContactName As String
-
Dim strFilter As String
-
' Check that the report is open
-
DoCmd.OpenReport "rptContacts", acPreview, , strFilter
-
' Build criteria string for Office field
-
If IsNull(Me.cboModel.Value) Then
-
strModel = "Like '*'"
-
Else
-
strModel = "='" & Me.cboModel.Value & "'"
-
End If
-
' Build criteria string for Department field
-
If IsNull(Me.cboContactName.Value) Then
-
strContactName = "Like '*'"
-
Else
-
strContactName = "='" & Me.cboContactName.Value & "'"
-
End If
-
' Combine criteria strings into a WHERE clause for the filter
-
strFilter = "[Model] " & strModel & " AND [ContactName] " & strContactName
-
' Apply the filter and switch it on
-
With Reports![rptContacts]
-
.Filter = strFilter
-
.FilterOn = True
-
End With
-
End Sub
-
-
Private Sub cmdRemoveFilter_Click()
-
On Error Resume Next
-
' Switch the filter off
-
Reports![rptContacts].FilterOn = False
-
End Sub
-
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: -
Private Sub cmdOpenReport_Click()
-
Dim strModel As String
-
Dim strContactName As String
-
Dim strFilter As String
-
strFilter = "1=1 "
-
' Build criteria string for Office field
-
If Not IsNull(Me.cboModel) Then
-
strFilter = " AND [Model] ='" & Me.cboModel.Value & "'"
-
End If
-
' Build criteria string for Department field
-
If Not IsNull(Me.cboContactName) Then
-
strFilter = " AND [Contact Name] ='" & Me.cboContactName.Value & "'"
-
End If
-
' Apply the filter and switch it on
-
DoCmd.OpenReport "rptContacts", acPreview, , strFilter
-
-
End Sub
-
For this i get the following error:
Run Time Error '3075':
Syntax error (missing operator) in query expression ' AND [Model]='*620".
Any help please!!
4 3511 NeoPa 32,573
Recognized Expert Moderator MVP
A question would be a good starting point. What do you want to know?
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
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.
Well thanks for all your help sport
Sign in to post your reply or Sign up for a free account.
Similar topics |
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?
|
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...
|
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
|
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.
|
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?
| |
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
|
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.
|
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...
|
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,...
|
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...
|
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...
| |
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...
|
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,...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |