Multiple Optional Criteria

Oct 1, 2006

I've had a look around this forum and haven't seen anything really matching my needs, but please feel free to point me in the right direction.

What I am trying to do (using macros & queries - very new to SQL / VBA) is filter by multiple fields, but also allow the user to choose to filter by different combinations of fields - such as searching for first name and suburb, or salesperson and customer source, or first name and salesperson, or suburb and customer source, or three options or one, etc etc.

There will only be a certain number of search fields, probably five or six, but how do I get the query to recognise that if one of the search boxes is blank, it should allow all records in that field and only search by the other criteria, but if all the search boxes are filled in, the results must match all the criteria?

Does this make any sense?

PS - I am planning to use a command button as an "Apply Filter" so that the filter only updates after the user has specified all the options they want.

View Replies


ADVERTISEMENT

Optional (multiple) Calendar Criteria

May 10, 2006

I am using this criteria with my calender on my form...

>=([Forms]![frmReport]![txtFrom]) And <=([Forms]![frmReport]![txtTo])

but I have 2 other date fields that I would like to query, so how do I go about making this optional?

Normally with a simple reference like:

Like([Forms]![frmReport]![txtFrom]) & "*"

with the form control's default value as * I tried working with that configuration but either it is not possible or I have the wrong syntax.

I'm open to a VB solution if anyone has one?

Note: I would only be using one of the date fields at any given time

thanks

View 2 Replies View Related

Making Criteria Optional

May 7, 2007

I have a form with an option group that depending on which one is selected, opens a report with a specific query as it's source. Part of the query looks at a listbox on the form. Here is the criteria for a field: [Forms]![frmOnSearch]![tboCollDev]
I want to make this criteria OPTIONAL. So if there is nothing selected in the listbox, the query should not look at that criteria. FYI, the value that is returned from the listbox is numeric.

Thanks
ScrmingWhisprs

View 2 Replies View Related

Using Optional Criteria For A Subform Query

Sep 4, 2005

Hi,

Is there a simple way to add optional criteria in a query for a subform? Basically, what I'm trying to do is have a number of comboboxes in the parent form that indicate what records are shown in the subform (these records could then be added and/or deleted). I would like to be able to have a combobox such as "Month" that would filter the data shown in the subform to that month. If no month is selected, then the subform would show all months.

Any help would be much appreciated.

View 2 Replies View Related

Modules & VBA :: Email Function Using Optional Parameters - Optional Argument Error

Aug 12, 2015

I keeping getting the error "Invalid use of Null" when i call my email function using optional parameters.

Code:
Email Me.ProjectID.Column(1), _
Me.ProjectAddress, _
Me.TaskDescID.Column(1), _
Me.TaskDescExt, _
strStatus, _
Me.TaskStatusID.Column(1), _

[Code] .....

View 4 Replies View Related

Forms :: Optional Search Criteria For Users

Feb 27, 2014

On the access form I have designed , I need to give optional search option to the users. I have the following search options on the form (screenshot attached):

From Date
To Date
Port
Vessel
Voyage
---------------------

The query is as follows:

SELECT dbo_VESSEL.VESSEL_NAME, dbo_VESSEL.VESSEL_CD, dbo_VESSEL.VOYAGE_NUM, dbo_VESSEL.PORT_CD, dbo_VESSEL.DEPART_ACTUAL_DT, dbo_VESSEL.DIVISION_CD
FROM dbo_VESSEL
WHERE (
(dbo_VESSEL.VESSEL_CD Like [Forms]![VESSDAT].[Form]![txtvessel]) OR
(dbo_VESSEL.VOYAGE_NUM Like [Forms]![VESSDAT].[Form]![txtvoyage]) OR
(dbo_VESSEL.PORT_CD Like [Forms]![VESSDAT].[Form]![txtport]) OR
(dbo_VESSEL.DEPART_ACTUAL_DT BETWEEN [Forms]![VESSDAT].[Form]![txtfromdept] And [Forms]![VESSDAT].[Form]![txttodept]));
----------------------

However, the form still prompts me to enter values for all the boxes and still doesnt show the correct data.

View 14 Replies View Related

Forms :: Search / Filter By Multiple (optional) Textboxes On Form

Aug 1, 2013

I'm relatively new to MS Access (using MS Access 2013 but the db should work on 2010, too) and try to develop a database for an NGO I'm working in. I created almost all the tables (all that I need for now) and made the relationships.

However now I start to create forms and later reports for the actual user. The database will store information about clients and track consultations and assistance the NGO gives to them. There will be around 50.000 to 70.000 clients in the main table. Every client has a specific Individual ID and is member of a family which itself has another specific Group ID.

Now here is my problem: The User usually searches for the respective family by the Group ID. I implemented this with a search query using the ID number of a search text box. All done and no big problem.

But sometimes the ID number is not known so the user needs to search by name (First and Last Name). I use to different textboxes for this and it works in a similar way like the number search by query (Like "*" & [Forms]![frm_SearchIC]![txt_LName] & "*"). All still good However since most of the clients are actually from arabic speaking countries, converting the names into the Latin alphabet is bound to fail and produce a lot of misspellings. Therefore I added 2 more textboxes and 3 comboboxes for the user to give more information about the client and therefore make it easier to search for the person. I was able to produce a query which gives you the right result if you have ALL information at hand. However, this is not always the case.

1) But I cannot find a way to tell the query that if the a certain textbox or combobox is empty, it shall just "ignore" it and use the information at hand. I tried this in the query by adding in the criteria OR .... Is Null. This is alright for one or two textboxes but for the many I have, it seems to be too many different combinations for the criteria. It just worked with some fields but others always had to be filled in...

2) If no information is given at all, the database should inform the user that he needs to enter at least on field. If nothing is found the user should get a msgBox saying "No IC matches your criteria".

3) The results of the searches should be given out in another form where the user can pick the person from 1-to-many results.

I attached a sample database with sample data and reduced tables, fields, and entries ...

View 6 Replies View Related

Queries :: How To Count Records Based On Multiple Criteria From Multiple Tables

Jan 4, 2014

I need to count records based on multiple criteria from two different tables. I have two tables (i.e. "tblTasks" and "tblTaskHistory"). The tables have a one-to-many relationship based on the "TaskID" field. "tblTasks" has a field called "AssignedTo" and "tblTaskHistory" has a field called "TaskStatus". I need to know how many tasks have been "reopened", the "reopened" status is located in the "TaskStatus" field in "tblTaskHistory". I need this count against a unique listing of employees which can be found in the "AssignedTo" field in "tblTasks".

View 4 Replies View Related

Optional Selection In Query

May 12, 2006

I have two drop-downs on a form along with a child form that shows data based on a query. If both drop downs have selections, say date and dept. then the query would change and the child would show the data - that works fine, but what if one of the drop downs didn't have a value selected, as in i select a date but just want all departments so select noting from the second dd - how would i write the query to reflect this optional selection?

View 6 Replies View Related

Reports :: Optional Footers On A Report?

Nov 19, 2014

Is it possible to have three different report footers on the same report? I want to show one footer at a time depending on a condition met in the detail section. I already know how to check the condition but I need to know how to do the rest.

Ex:
if condition1 = A then
me!reportfooter_1.visible = true
me!reportfooter_2.visible = false
me!reportfooter_3.visible = false
end if

View 7 Replies View Related

Modules & VBA :: INSERT With Optional Fields?

Jun 5, 2013

I currently have a bound form that adds a new student, however, I've decided I don't like bound forms as weird stuff can happen (like when the user exits in another way than I anticipated) so I'm making an unbound form which will add the student when a button is clicked. I already have this working on some other places so this should be no problem anymore.

However in my database a lot of student information is optional and only a first and last name are required (and ofcourse an autogenerated PK). So my question is how do I deal with these fields that might or might not be empty?

I could make a fairly big If ... ElseIf... construction where I slowly fill a String with all the optional fields but I was wondering if maybe there are some better ways to approach this?

View 12 Replies View Related

Queries :: Third Combo Box On A Form To Be Optional

Feb 24, 2015

How to get a third combo box on a form to be optional.

I have a form with two combo boxes which filter out the results on a query.

However I want the third combo box to be optional i.e. if it is blank then just the results of the first two combo boxes are shown. If the user selects all combo boxes then obviously the results are based on all combo box selections.

View 7 Replies View Related

General :: Argument Not Optional For Field

Apr 24, 2015

I have a subform and when you double click on any field it remembers 3 fields from the record you are in and stores them. I have 3 fields called [section], [losthrs], [stdhrs]. It works perfectly and stores the data from [losthrs] and [stdhrs] fields, but throws up "Argument not optional" for the [section] field.... Can not see a reason why, it is just a simple text field...

I have even tried 'pausing the code' and using the immediate window to show the field values, again losthrs and stdhrs are fine, section gives "Argument not optional".

View 4 Replies View Related

Compile Error - Argument Not Optional

Jul 30, 2015

Windows XP
Access 2007

I have followed Martin Green's steps (fontstuff) for creating an audit trail and am getting a compile error when I check my code.

This is my code and the error highlights 'Call AuditChanges' as the problem.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Me.NewRecord Then
Call AuditChanges("ImprovementID")
End Sub

View 5 Replies View Related

Modules & VBA :: Function - Can A String Be Optional Variable?

Aug 26, 2014

I am amending some Code I found online for an audit table, I need to store additional information in the table that is associated with some forms but not others.

I have researched about putting optional variables in, but I read this only works with the type VARIANT.

Is there a way to make a string optional as my fields contain text?

here is my code so far:

Sub AuditChanges(IDField As String, UserAction As String, Optional UserID As String, Optional DeviceID As String, Optional SimID As String)
On Error GoTo AuditChanges_Err
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim ctl As Control
Dim datTimeCheck As Date

[Code]...

View 5 Replies View Related

Forms :: Calculation In A Field - Getting Argument Not Optional Error

Sep 18, 2014

Trying to create a calculation in a field (text25) that excludes weekends and holidays. I am getting an argument not optional error.

Code : Me.[Text25] = GetBusinessDay([Due_Date - Result_Date])

View 14 Replies View Related

Forms :: Email Using User Selected HTML Template With Optional Report As Attachment

Jun 27, 2015

I have an access form. It has

-Two textboxes with client first and last name
-Two textboxes with a contact 'email1' and 'email2' for the client
-A combobox with a list of templates to use for the email.
-A checkbox to include a copy of the statement on the email.

I want the user to be able to press a button which does the following

-Sends an email to both 'email1' and 'email2'.
-Attaches a secific report as PDF if the user has selected the checkbox
-The body of the email includes a greeting line using the clients name from the record.
-The body of the message includes below the greeting line a html email template depending on the users combobox selection.

View 3 Replies View Related

Multiple Criteria

Jun 22, 2005

Is it possible to have more than 9 OR criteria in an update query?

Thanks,
SKK

View 1 Replies View Related

Multiple Criteria

Jul 20, 2005

hi. my name is tim. im having some problems with a query that I am writing. it should be rather simple and involves only one table.

the table is called tblCustomer. The query involves 2 fields: cResort and cWeek. Neither of these fields are unique. Together they make up the primary key.

cResort is populated with a textfield: PF, PV, and GS.
cWeek is populated with an integer: 1-52 (the number of weeks in a year)

This is what the query is supposed to do:
SELECT tblCustomer.*
FROM tblCustomer
WHERE cResort DOES NOT EQUAL "PF" AND WEEK is LESS THAN 10

here's where the problem lies, this filters out ALL "PF" and ALL cWeek < 10.

I want PF's with a corresponding cWeek from 1-10. I dont want to see PFs with corresponding cWeek 11-52.

Example:
Show me cResorts: PF with corresponding cWeek:1-10.
Do NOT show me cResorts: PF with corresponding cWeek:11-52.

Is this clear? Thank you for the help.

View 6 Replies View Related

Multiple Criteria

Mar 29, 2006

I am trying to construct a fairly complex query on the fly. I have it working except for the criteria side of the query which I am having trouble with. It doesn't really matter about the vb side of it because I can alter the construction easy enough. it is more a question of how I get the criteria right.

I'll show you the SQL below first:

SELECT DISTINCTROW tblCandidate.CandidateID, tblCandidate.FirstName & ' ' & [Surname] AS Name, tblCandidate.Telephone, tblCandidate.Mobile, tblCandidateAvailability.Status, tblCandidate.CandidateID AS [Count]
FROM ((tblCandidate LEFT JOIN tblCandidateArea ON tblCandidate.CandidateID = tblCandidateArea.CandidateID) LEFT JOIN tblCandidateJobCode ON tblCandidate.CandidateID = tblCandidateJobCode.CandidateID) INNER JOIN ((tblBranchDetail RIGHT JOIN (tblCandidateAvailability INNER JOIN tblBooking ON tblCandidateAvailability.AvailableDate = tblBooking.ScheduleDate) ON tblBranchDetail.BranchID = tblBooking.BranchID) INNER JOIN tblBookingDetail ON tblBooking.ScheduleID = tblBookingDetail.ScheduleID) ON tblCandidate.CandidateID = tblCandidateAvailability.CandidateID
WHERE (((tblCandidateAvailability.Status)='Available') AND ((tblBookingDetail.ScheduleDetailsID)=103) AND ((tblCandidateJobCode.JobCode)='DO') AND ((tblCandidateArea.PostCodeID)='HP')) OR (((tblCandidateAvailability.Status)='Available') AND ((tblBookingDetail.ScheduleDetailsID)=105) AND ((tblCandidateJobCode.JobCode)='DO') AND ((tblCandidateArea.PostCodeID)='DO')) OR (((tblCandidateAvailability.Status)='Available') AND ((tblBookingDetail.ScheduleDetailsID)=106) AND ((tblCandidateJobCode.JobCode)='DO') AND ((tblCandidateArea.PostCodeID)='HP'));

The table structuring is fine it is the SQL after the WHERE statement that I am having trouble with.

This query works fine to give me all Candidates that comply with these criteria. The only trouble is I want to only results where the Candidate(s) ALL three set of criteria. I have tried replacing the OR with AND and using extra brackets to enclose the whole WHERE statement to imply I need all criteria met but this reports back no results despite me having test data where a candidate meets all criteria.

I am sure this is not as hard as I am making it but I can't figure it out at all.

I also ideally wanted to show only one record (ie one candidate that meets all instead of three records showing the candidates). This is not so important as I can work this out easily enough, by probably hiding fields I don't want to see and showing only unique values, etc...

Can anyone help me with this?

Thanks in advance,

Daz

View 14 Replies View Related

Multiple Criteria Using IIF

Apr 8, 2006

:eek: I am looking for a method that works in query criteria (NOT HARDCODING SQL) as i am quite new to this.:eek:

i have two fields for query to lookup, firstname and lastname.

THE FIRSTNAME FIELD:

IIf(IsNull([Forms]![frmSearch]![FirstName]),"",[Forms]![frmSearch]![FirstName])

THE LASTNAME FIELD:

IIf(IsNull([Forms]![frmSearch]![LastName]),"",[Forms]![frmSearch]![LastName])



Intended operation;
1) The value is seen on my search form (frmsearch) and returned to FIRSTNAME and LASTNAME query fields as NULL or VALUE.

2) If on the search form FIRSTNAME has value and LASTNAME is NULL then query should lookup a record with valid FIRSTNAME and nothing in LASTNAME.

3) If on the search form LASTNAME has value and FIRSTNAME is NULL then query should lookup a record with valid LASTNAME and nothing in FIRSTNAME.

4) If on the search form FIRSTNAME and LASTNAME have value (NOT NULL) then lookup record with valid FIRSTNAME and LASTNAME.

5) If no information is entered on the search form then "enter some information" as message box.

6) I would want wildcard using which also doesn't seem to work in IIF statement. e.g. "*" & [Forms]![frmSearch]![FirstName] & "*"

THERE FORE ---> IIf(IsNull("*" & [Forms]![frmSearch]![FirstName] & "*"),"","*" & [Forms]![frmSearch]![FirstName] & "*")



ONLY NUMBERS ABOVE (2) (3) AND (6) DO NOT WORK, IF ANYONE COULD GIVE SOME LIGHT ON THIS I WOULD BE VERY GRATEFUL, AS I AM IN THE BLUE ON THIS.:rolleyes:

TAKE IT EASY:D

View 3 Replies View Related

Multiple Search Criteria

Apr 26, 2005

Wonder if you guys can help me with something. I have a table with about 1200 guests, what I want to do is to search the table base on different criteria (or combination of criteria), namely phone #, name, street name, and postal code. Not everyone has all this info, and their names aren't separted into proper lastname or firstnames (old data).

What I want to do is to be able to type in a person's first name, last name, or both (an maybe other info if the first search wasn't successful).

http://www.psynic.com/files/access.jpg

What should I do to implement this? I was thinking of running 4 different queries, and interesect them into the final query. What do you think?

View 2 Replies View Related

Dcount With Multiple Criteria

May 16, 2005

Not sure if this belonged in reports or queries, so I chose general. I have looked at several DCount threads but haven't quite found my answer. I want to use Dcount in an unbound textbox in a report. It counts the number of records in another table - comparison
the first part of the statement works fine ( up to 'iss'"). When i added the between date part i'm not getting any # returned in my report. I want to addthe criteria of RecDate between the 2 dates on the open form.
Can anyone tell me where my problem lies? ( if this makes sense)

Thanks
Kevin


=DCount("[type]","comparison","[type] Like 'iss*'" And ("[comparison].[RecDate]" Between Forms!DateInputforRMAsReturned!Text0 And Forms!DateInputforRMAsReturned!Text2))

View 14 Replies View Related

Multiple Criteria In Query

May 14, 2005

Hello all:

I need your urgent help with the following:

I am setting up a query in access. I have about 4 criteria for one of the fields called Center, I want the query to do the following:

Return all rows if:
Center is Like 6101*
Center is Like 61HKS56800
Ignore row if Center is Like 6101D*
Ignore row if Center is like 6101SALM01

I put in the following and I am not getting the correct results:

Like "6101*" Or Like "61HKS56800*" And Not Like "6101D*" And Not Like "6101SALM01"


Thanks,
Odun

View 1 Replies View Related

Multiple Grouping Criteria

May 30, 2006

I am trying to produce a report or query that lists 11 attributes for several projects measured each month over the duration of each project. i.e. It is required to have the attributes for project A listed (horizontally) for months 1,2,3,...etc (vertically) followed by those for projects B for months 1,2,3,4,5,6... etc. Can anyone advice on how to do this please?

View 2 Replies View Related

Query With Multiple Criteria

Aug 24, 2006

Hi all,

I'm working on a purchasing app in access. At this point i'm working on the reporting module. I want a user to be able to fill out a start date (text box), end date (text box), and select a code from a list, hit Run Query, and have it pull up a report listing the date that the selected code was used, between the start and end date, and display other info as well.

The problem i'm having is that i can get the date ranges to work, or the code to work, but not both of them. Here's what i have in my query:

http://content.imagesocket.com/images/gl_codes2ff.JPG

I'm really lost here. Any advice would be appreciated.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved