Criteria Returning Wrong Results/WHERE Clause Length

Jul 19, 2006

Hi there,

I'm working on a select query that I have created through the visual query design window in Access 2003, I have multiple criteria but the query is not filtering the results properly.

I'm selecting only records :

where the DeliveryCountry field is within the EU - works
where the ProductID does not contain Repair, Upgrade or Rpr - doesn't work
where the Demo/Sale ID is 2 - works


I've viewed the code in SQL view but I still can't locate the problem, though I suspect it lies in the treatment of ANDs and ORs.

The SQL is pasted below (I have reformatted with indentations so I hope it is easier to read).

One thing to note: the reason the countries list is split in two is because Access did this automatically when I had one long list. Is there a maximum length for WHERE clauses?

Thanks in advance for your help!

Abby

SELECT Orders.ShipDate, Products.[Standard Tarriff Number], [Order Details].[Quantity]*[Order Details].[unitprice]*(1-[discount])*(1-[special discount]) AS [Line Total], [Order Details].Quantity, Orders.OrdDeliveryCountry, Orders.OrderID, [Order Details].ProductID

FROM Products RIGHT JOIN (([Demo/Sale] RIGHT JOIN Orders ON [Demo/Sale].[Demo/SaleID] = Orders.[Demo/SaleID]) LEFT JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID

WHERE (((Orders.OrdDeliveryCountry)="Austria" Or (Orders.OrdDeliveryCountry)="Belgium" Or (Orders.OrdDeliveryCountry)="Cyprus" Or (Orders.OrdDeliveryCountry)="Czech Republic" Or (Orders.OrdDeliveryCountry)="Denmark" Or (Orders.OrdDeliveryCountry)="Estonia" Or (Orders.OrdDeliveryCountry)="Finland" Or (Orders.OrdDeliveryCountry)="France" Or (Orders.OrdDeliveryCountry)="Germany" Or (Orders.OrdDeliveryCountry)="Greece" Or (Orders.OrdDeliveryCountry)="Hungary" Or (Orders.OrdDeliveryCountry)="Ireland" Or (Orders.OrdDeliveryCountry)="Italy" Or (Orders.OrdDeliveryCountry)="Latvia" Or (Orders.OrdDeliveryCountry)="Lithuania" Or (Orders.OrdDeliveryCountry)="Luxembourg" Or (Orders.OrdDeliveryCountry)="Malta")
AND (([Order Details].ProductID) Not Like "*Upgrade")
AND ((Orders.[Demo/SaleID])=2))
OR (((Orders.OrdDeliveryCountry)="Austria" Or (Orders.OrdDeliveryCountry)="Belgium" Or (Orders.OrdDeliveryCountry)="Cyprus" Or (Orders.OrdDeliveryCountry)="Czech Republic" Or (Orders.OrdDeliveryCountry)="Denmark" Or (Orders.OrdDeliveryCountry)="Estonia" Or (Orders.OrdDeliveryCountry)="Finland" Or (Orders.OrdDeliveryCountry)="France" Or (Orders.OrdDeliveryCountry)="Germany" Or (Orders.OrdDeliveryCountry)="Greece" Or (Orders.OrdDeliveryCountry)="Hungary" Or (Orders.OrdDeliveryCountry)="Ireland" Or (Orders.OrdDeliveryCountry)="Italy" Or (Orders.OrdDeliveryCountry)="Latvia" Or (Orders.OrdDeliveryCountry)="Lithuania" Or (Orders.OrdDeliveryCountry)="Luxembourg" Or (Orders.OrdDeliveryCountry)="Malta")
AND (([Order Details].ProductID) Not Like "*Repair")
AND ((Orders.[Demo/SaleID])=2))
OR (((Orders.OrdDeliveryCountry)="Austria" Or (Orders.OrdDeliveryCountry)="Belgium" Or (Orders.OrdDeliveryCountry)="Cyprus" Or (Orders.OrdDeliveryCountry)="Czech Republic" Or (Orders.OrdDeliveryCountry)="Denmark" Or (Orders.OrdDeliveryCountry)="Estonia" Or (Orders.OrdDeliveryCountry)="Finland" Or (Orders.OrdDeliveryCountry)="France" Or (Orders.OrdDeliveryCountry)="Germany" Or (Orders.OrdDeliveryCountry)="Greece" Or (Orders.OrdDeliveryCountry)="Hungary" Or (Orders.OrdDeliveryCountry)="Ireland" Or (Orders.OrdDeliveryCountry)="Italy" Or (Orders.OrdDeliveryCountry)="Latvia" Or (Orders.OrdDeliveryCountry)="Lithuania" Or (Orders.OrdDeliveryCountry)="Luxembourg" Or (Orders.OrdDeliveryCountry)="Malta")
AND (([Order Details].ProductID) Not Like "*Rpr")
AND ((Orders.[Demo/SaleID])=2))

OR (((Orders.OrdDeliveryCountry)="Holland" Or (Orders.OrdDeliveryCountry)="Poland" Or (Orders.OrdDeliveryCountry)="Portugal" Or (Orders.OrdDeliveryCountry)="Slovakia" Or (Orders.OrdDeliveryCountry)="Slovenia" Or (Orders.OrdDeliveryCountry)="Spain" Or (Orders.OrdDeliveryCountry)="Sweden")
AND (([Order Details].ProductID) Not Like "*Upgrade")
AND ((Orders.[Demo/SaleID])=2))
OR (((Orders.OrdDeliveryCountry)="Holland" Or (Orders.OrdDeliveryCountry)="Poland" Or (Orders.OrdDeliveryCountry)="Portugal" Or (Orders.OrdDeliveryCountry)="Slovakia" Or (Orders.OrdDeliveryCountry)="Slovenia" Or (Orders.OrdDeliveryCountry)="Spain" Or (Orders.OrdDeliveryCountry)="Sweden")
AND (([Order Details].ProductID) Not Like "*Repair")
AND ((Orders.[Demo/SaleID])=2))
OR (((Orders.OrdDeliveryCountry)="Holland" Or (Orders.OrdDeliveryCountry)="Poland" Or (Orders.OrdDeliveryCountry)="Portugal" Or (Orders.OrdDeliveryCountry)="Slovakia" Or (Orders.OrdDeliveryCountry)="Slovenia" Or (Orders.OrdDeliveryCountry)="Spain" Or (Orders.OrdDeliveryCountry)="Sweden")
AND (([Order Details].ProductID) Not Like "*Rpr")
AND ((Orders.[Demo/SaleID])=2))

ORDER BY Orders.ShipDate DESC;

View Replies


ADVERTISEMENT

WHERE Clause Using Between And DateAdd Not Returning Correct Results

May 4, 2006

I have the following two querydefs. Here is the SQL;
qry1
SELECT [dtFind], tblData.dtReading, tblData.dblValue
FROM tblData
WHERE DateDiff("n",[dtReading],[dtFind]) Between 1 And CInt([intMins]);

qry2
SELECT [dtFind], tblData.dtReading, tblData.dblValue
FROM tblData
WHERE dtReading Between DateAdd("n",-1*[intMins],[dtFind])
And DateAdd("n",-1,[dtFind]);

[dtFind] and [intMins] are parameters.

I use the querydefs is VBA code as such
Dim db As DAO.Database
Dim rstDataSQL as DAO.Recordset
Dim qdfData As DAO.QueryDef
Dim strQdef As String

Set db = CurrentDb()
strQdef = "qry1" ‘or qry2
Set qdfData = db.QueryDefs(strQdef)

‘Set values of parameters
qdfData![dtFind] = dtDate
qdfData![intMins] = intMins

Set rstDataSQL = qdfData.OpenRecordset

qry2 executes significantly faster than qry1, but I am having issues getting the correct results.

If I set [dtFind] = 12/28/2005 10:47:00 AM, both queries work fine. The last returned record has a value for dtReading of 12/28/2005 10:46:00 AM.

However, if I set [dtFind] = 12/28/2005 10:48:00 AM, only qry1 returns the right records. qry2 will not return the record with dtReading = 12/28/2005 10:47:00 AM, but qry1 will.
:mad:

I changed the Between statement to “Between DateAdd("n",-1*[intMins],[dtFind]) And DateAdd("n", 0 ,[dtFind])” to see what happens. As I expected, records where dtReading = 12/28/2005 10:47:00 AM and 12/28/2005 10:48:00 AM are returned.

The data should be in increments of 1 minute, although there are periods where data is missing. None of the dates have values like 12/28/2005 10:47:01 AM, i.e. seconds value is always 0.

I’ve tried adding “PARAMETERS [dtFind] DateTime, [intMins] Short;”, and also using CDate(DateAdd()) without any luck.

Whether I am using the queries using VBA/DAO or user input to set the parameter values, the results are the same.

What am I doing wrong?
:confused:

View 4 Replies View Related

Queries :: Query Returning Wrong Results?

May 7, 2014

I have two tables Contacts & Allowance. There is a relationship defined between the two based on Contact ID (primary field/contacts - foreign key/allowance). The Contacts table has Firstname + Surname. I have produced a query based on certain fields in both tables however the result is totally pulling incorrect info.

View 11 Replies View Related

Forms :: Combo Box Returning Wrong Results In Access 2010

Jun 11, 2014

I have an unbound combo box that I set up in a form using the combo box wizard in Access 2010. I selected the option that says, "Find a record on my form based on the value I selected in my combo box." The problem is that the combo box will not always display the correct record. It seems to only display the first record of a group of similarly named records in a table.

Example:

Code:
Last Name First Name SSN
Smith Alex 123-45-6789
Smith Jane 234-56-7891
Smith Mary 345-67-8910

If I select Smith Jane, the record for Smith Alex will display. I know that this has something to do with the bound column property, but I am unsure what to do to fix the issue.

What I have tried: I tried setting the primary key as the first field, but then I could only search by the primary key, which is unrealistic for this database. Users will be searching based on last name. How do I make the combo box select whichever record I select from the drop down list?

View 4 Replies View Related

Wrong Number Of Rows Returned By Subquery With Top Clause

Mar 21, 2007

I have a strange 'bug'.

I wrote a query to return the TOP 32 items for a key. Works fine:-

SELECT TOP 32 [my Disks Coefficients sub].[thier Disk ID] FROM [my Disks Coefficients] AS [my Disks Coefficients sub] WHERE [my Disks Coefficients sub].[my Disk ID]=1 GROUP BY [my Disks Coefficients sub].[thier Disk ID], [my Disks Coefficients sub].coefficient ORDER BY [my Disks Coefficients sub].coefficient;


I then plugged this into a query in the WHERE clause using In (Select Top .....;); [changing the =1 condition to pick up the correct id from the emcompassing query]:-

SELECT [my Disks Coefficients].[my Disk ID], [my Disks Coefficients].[thier Disk ID], [my Disks Coefficients].coefficient FROM [my Disks Coefficients] WHERE [my Disks Coefficients].[thier Disk ID] In (SELECT TOP 32 [my Disks Coefficients sub].[thier Disk ID] FROM [my Disks Coefficients] AS [my Disks Coefficients sub] WHERE [my Disks Coefficients sub].[my Disk ID]=[my Disks Coefficients].[my Disk ID] GROUP BY [my Disks Coefficients sub].[thier Disk ID], [my Disks Coefficients sub].coefficient ORDER BY [my Disks Coefficients sub].coefficient;);

This runs fine but the the number of items returned is for each key is less than if I run the Top query by itself for each key seperately? So when I run it stand-alone for ID 1 I get 127 rows (there are many equal coefficients); when I run it as a sub-query I get only 121 rows for ID 1!

Anyone any ideas?

Martin

View 8 Replies View Related

Forms :: Expression On Text Box Returning Wrong Value

Mar 29, 2013

I have a form used for taking inventory. One table to lookup items, one for writing values. Tables linked by an ID #. I created a text box on my form to lookup a value called PARQTY in the lookup table. I need to be able to subtract that value from the QTY that is entered into the Qty_Counted box on teh same form when they take inventory.

I created a new Text box and in the control source for it, I entered an expresion that basically says subtract The PARQTY from the QTY_COUNTED it reads = [QTY_COUNTED] - [PARQTY]

The box is subtracting the QTY_COUNTED from the ID # that is linking my two tables and displaying it. Its not supposed to be subtracting the QTY_COUNTED at all. It should be subtracting the PARQTY value that is displayed from the QTY_COUNTED. The PARQTY box does display the right value from the lookup table so I can't figure out why it's pulling that ID number or where from. The rest of the form / program works and we've been using it for a few years. I also created that, but like now, I had to muddle through each and every little thing I did.

View 9 Replies View Related

Dcount Giving Wrong Results

Jun 14, 2006

Hi Folks,

I have answered my own question so I thought I would share as I couldn't find the solution in any posts. I confess that I don't understand why my results were wrong, but I managed to get them right. :rolleyes:

When using Dcount in a query, I was getting results which did not match the query results. For instance:

Phase_2: DCount("Project_Phase_ID","tbl_Prj_Details","Project_Phase_ID = 2")
gave an answer of 27 when there were in fact 41 projects in that phase.

Searching the forum I came accross this:

Count() always counts the entire domain.

So, Dcount is not counting the record set of my query but something else. I have 4 tables in the query and no idea what domain my dcount was looking at. I presume the various join types were messing with it somehow. :confused:

To get round this, I stripped out the Dcount expressions and changed the query to a make table. I then used the created table as the basis of a query in which I had my Dcounts. The dcount results now agree with the query recordset. :) :) :)

Any background on the bits I clearly don't understand will be gratefully received. I hope this helps someone else sometime.

Kind regards,

Keith.

View 3 Replies View Related

Query Not Returning Results

Jun 23, 2005

Hi,

I have a query with two table's in them. One is filled, the other is still empty.
Both table's are related to each other with the field "document number".

This was working fine in access 2000, now in 2003 it returns zero results.
I am starting to think it is because one table is empty it returns nothing.
How can i adapt the query criteria or something else that it shows the results from table one, while table two can still be empty.
One table holds the documents and all information about it, the other holds the information wich document is referenced on wich document. Now since i can have documens which don't reference to a document, i still want those in the list.

Anybody any idea?

Thanks

View 1 Replies View Related

Query Not Returning All Results

Jul 6, 2007

I have a table listing a number of cell phone products and their carrier along with their status' in the production process. I want the query to return the most recent status for each product for each carrier. However, out of the 20+ products that I'd like the most recent status for for each carrier, it's only returning about 12 products of the most recent status for one carrier.

Any help would be much appreciated! Leave a message if you need more clarification.

Thanks!

View 3 Replies View Related

Modules & VBA :: 2nd Run Of A Function Calculates Wrong Results?

Jul 21, 2014

i am using the following function in a query:

Code:
Public Function Progress(ByVal varCompany As Variant _
, ByVal varPercent As Variant) As Variant
Static varCompanyOld As Variant
Static varValueOld As Variant
Dim Value As Variant
If varCompany & vbNullChar = varCompanyOld Then
Value = (1 + varPercent) * varValueOld
varValueOld = Value

[code]....

This function is working if I use it with two or more companies.If I have only one company, it works at the first (query) run, too.But with the same company, a second (query) run calculates different results.

I think it is because of this condition:

Code:
If varCompany & vbNullChar = varCompanyOld Then ...

If the company name is e.g. Microsoft

At the first run of the query:

Microsoft & vbNullChar = "" -> wrong

The Else calculation will be carried out.

-> That is right for the first datapoint of a company

At a second run of the query:

varCompanyOld is saved as Microsoft & vbNullChar, so:

Microsoft & vbNullChar = Microsoft & vbNullChar -> True

The main calculation will be carried out.

-> That is wrong for the first datapoint of a company

View 14 Replies View Related

Search Function Returning Zero Results On 2nd Use

May 15, 2007

Item: Access app front end for an SQL database (production tracking/job logging utility)

Problem: The app has a main search page that allows job entries to be located and opened by varies criteria (job#, job name, etc). I can currently run multiple searches on different criteria successfully but if I open a job window(which has been returned as result of my search) and then close that job window to do a new search my search function will no longer return any results(other then “Calculating….”) unless I close out the access app and reload.

Thanks in advance for any ideas that can point me in the right direction to hunt down my bug.

View 1 Replies View Related

Query Not Returning Correct Results

Jul 3, 2006

Hi everyone,

I'm having an issue with a query I created. When run the query requests an Artist Name. I enter this and it returns one result. However in actual table ther are two results for that artist. The only difference is that for the record that doesnt appear the field labelled "Gallery" has a zero value.

I have checked the table and the gallery field is not set to a required field so I dont understand why it wont show it as a result of the query.

Any ideas?

View 3 Replies View Related

Query Returning MORE Results Than Expected

Mar 2, 2007

Hi all:

running access 2000. I have a query that I selected to return the Top 1 record sorted descending on the date so it would pick the most recent entry. I did it by selecting Top 5 from the drop down box in query design mode and then changed the 5 to a 1 using SQL View from qry design.

SELECT TOP 1 Class.CourseID, User.UserName, Class.TrainerID, Class.ClassLocationID, Class.ElapsedTime, Class.ClassDate, Class.Comments
FROM [User] INNER JOIN Class ON User.UserID = Class.UserID
ORDER BY Class.ClassDate DESC;

It still gives me as many records as are entered on the system. How can I get JUST the most recent record entry?

thanks:confused:

View 3 Replies View Related

Random Dropdowns Not Returning Results

Aug 18, 2005

I have built a Project/Resource database for our department, and I am having an issue with 3 computers in the group. First, all of our computers are setup the same (as far as I can tell), however, there are 3 users that have the same issue...when selecting an item from a dropdown, it should populate the dropdown below it with a new list, based on the first dropdown. It is only on certain forms, and only happens on these three computers. If the users log into any other computers, it works fine. I know it's not alot to go on, but does this sound familiar to anyone? I'm at a complete loss!

View 5 Replies View Related

Append Qry Not Returning Desired Results

Jan 17, 2005

I have built a query that should append to another table. Please see SQL below -

INSERT INTO tblMyBackupContent ( LoginName, Title, Type, Code, [Date Assigned], [Date Started], [Last Accessed], Progress, [Date Completed], [Time Spent (min)], Score, Result )
SELECT tblConentImport.LoginName, tblConentImport.Title, tblConentImport.Type, tblConentImport.Code, tblConentImport.[Date Assigned], tblConentImport.[Date Started], tblConentImport.[Last Accessed], tblConentImport.Progress, tblConentImport.[Date Completed], tblConentImport.[Time Spent (min)], tblConentImport.Score, tblConentImport.Result
FROM tblConentImport
WHERE (((tblConentImport.LoginName)="iderand"));

When I run this query, it shows that 41 records are going to be appended. I click on yes, but when I go into the table to view the appended records they do not show.

Please help me.

View 1 Replies View Related

Modules & VBA :: DLookup Not Returning Any Results

Mar 26, 2014

Here is my VBA Dlookup Code:

Code:
Public Sub test()
Dim frm As Form
Set frm = Forms!StationLevelSummary

[code]...

At the bottom im printing the content of the controls which are on my form. These should return 1 number, but for some reason it does not. Ive used this code many times but I cant figure out why nothing is being returned.

View 4 Replies View Related

Modules & VBA :: Like Function Returning Odd Results

Jan 13, 2014

I'm trying to do a string compare between two variables. One string variable is part of an array (which I'm looping through), the other is passed to the function as an argument.the function should return the position of a field in the OrderBy string of a subform.Here's the VBA :

Code:

Private Function SortPosition(strOrderBy As String, strField As String) As StringDim arrSortedFields() As String
Dim i As Long
If Len(strOrderBy) > 0 And InStr(strOrderBy, strField) > 0 Then
arrSortedFields = Split(strOrderBy, ",")

[code]....

The weird thing is, the line in blue returns True when, by watching the variables, it appears that it should not, and returns False when it appears that it should?

arrSortedFields(i) = "[RandomField]"
strField = "RandomField"
arrSortedFields(i) Like "[" & strField & "]*" = False
arrSortedFields(i) = "[SomeFieldName]"
strField = "ADifferentField"
arrSortedFields(i) Like "[" & strField & "]*" = True

I would have thought the expression "[RandomField]" Like "[RandomField]*" should return True?And similarly the expression "[SomeFieldName]" Like "[ADifferentField]*" should return False?Have been using 'Like' for donkey's years and never seen it throw results like this before?

(P.S. The reason I need to use 'Like' rather than a straight = is to account for the possibility that a field may be sorted descending, and therefore to nullify the DESC keyword which may follow any given field...)

View 9 Replies View Related

Select Query Returning No Results?

Sep 12, 2012

I have a db with 2 tables, one containing basic info FirstName, Surname, YearGroup, and another table with other data. I imported a list of names into the first table, firstname and surname only were imported, other field was left empty, other table was also left empty. I made a simple select query to pull all records from both tables and i get no results at all. None of the imported names show on the query results. what I am missing?

View 2 Replies View Related

Criteria Text Length Issues With Query

Oct 13, 2005

Hi All,

I've been developing the code below but when the length of .lstAnswers is longer than 128 it doesn't delete the question.
Is there a reason under queries or SQL this should happen? I'm hoping that i'm just thick and there's an easy answer but nothing seems to work.

--------------------------------------------------------------------------
Private Sub cmdRemoveAnswer_Click()
Dim Answers_SQL As String
Answers_SQL = "DELETE tblOptions.* " & _
"FROM tblOptions " & _
"WHERE (((tblOptions.strAnswer)=[Forms]![frmQuestionWizard]![lstAnswers]) AND ((tblOptions.strQuestion)=[Forms]![frmQuestionWizard]![lstQuestion])) OR (((tblOptions.strAnswer) Is Null))"
DoCmd.RunSQL Answers_SQL, 0
lstAnswers.Requery
End Sub

--------------------------------------------------------------------------

View 2 Replies View Related

Query Returning Case-sensitive Results!?!

May 22, 2006

I am using the following:

SELECT CPL_CLIENTS.CODE, CPL_CLIENTS.FULLNAME FROM CPL_CLIENTS
WHERE (((CPL_CLIENTS.FULLNAME) Like "*" & Forms!frmSafeKeep_AddClient_SearchDesig!txtSearchT ext & "*"));

As the control source of a listbox, so that the user can enter something in "txtSearchText", and the listbox will be narrowed to only those those clients that have a matching part of their name.

The problem is that the user enters, for example, "duncan", and the list returns nothing, when in actual fact there are 5 matching records. If the user enters "Duncan" (note the capital letter), they get all 5 records as they should.

If memory serves, access should only be case sensitive if you tell it to be - and this is working fine on other forms.

The only difference between them is the data source. Other forms are getting data from linked tables in the backend. This form is getting it from a linked Oracle table.

View 4 Replies View Related

Queries :: Like Not Returning Results On Date Format

Oct 6, 2014

I have a query which pulls up results based on the value of a text box. All works well except one field has a DOB (date) and if I search say for " /1976" I get no results, however search /76 and all the people with that year of birth show then show up. The date is stored in the dd/mm/yyyy format.

I'm using the like [forms]![clients]![searchfield] in the criteria of the query to bring up results.

View 10 Replies View Related

Forms :: Search Listbox Results Point To Wrong Records

Jul 31, 2015

So I created a search form which filters my results. Apparently I don't have enough posts to link to the source of the code though. The code is from this website, /forums/showthread.php?t=188663

I then wanted to allow users to double click a result in the listbox to take them to the form which contains details about that record, however the listbox doesn't point to the correct record.

-When nothing is specified in the search field, all records are shown in the listbox, but double clicking on the first record takes me to a form that has no information. Clicking the second record takes me to the Detail Form of the first record.
-When information is put into the search field, the results are filtered and only a few display, however clicking the first result again takes me to a blank form while the second result takes me to the first record of the unfiltered list. There is no way to reach the Detail Form for the last result of the listbox.
-I tried right clicking the results in the listbox and copy pasting the information. The first result gave me a "0", the second a "1", and so on and so forth. This was the same whether or not the information was filtered or not.
-I tried switching to a combo box and got the same results.

View 2 Replies View Related

Modules & VBA :: OpenForm Command Where Clause With 2 Criteria

Oct 31, 2013

I am having trouble opening Form 2 to the same record as the record in Form 1. Form 1 is a continuous form of questions. When certain response is given, I want to be able to add more information to the "additionalcomments" column for that record. I want to have the additional comments pop up in a new form.

Form 1 is based off of a query with no unique ID. I need the second form to open on Eval_Number and Question_Number. I have tried...

Code:
If Me.Response = 0 Then
DoCmd.OpenForm "frmadditionalcomments", acNormal, , "[Eval_Number] =" & Forms!ESVWL1Trainee!subfrmreponses.Eval_Number And [Question_Number] = " & Forms!ESVWL1Trainee!subfrmreponses.Question_Number "
End If

and this tells me the object doesn't support the method. Is the SQL incorrect? Is it the way its setup?

View 5 Replies View Related

Queries :: Search Not Returning Results With A Blank Entry

Oct 25, 2013

I have a switchboard which runs a google style search query to find people based on their first name, surname, date of birth or NI number on clicking the search button. It uses the following criteria in the query Like "*" & [Forms]![SearchF]![Firstname] & "*" for each of the above fields.

This works perfectly until someone inputs a record that doesn't have anything in one of the fields. ie, full name and DoB, but no NI number. When a record is entered in this way, the table stores the record but the search query cannot find it.

View 3 Replies View Related

Queries :: Nested IIF - Returning Calculated Results In A Query

Oct 30, 2013

What is the best approach to returning calculated results in a query. I have been using nested IIf statements that include DateAdd but I think that I am at a point where there must be a better way.

I want my query to calculate a date based on:
1) A Type field from my table
2) A calculated date based on other query fields.

My query has the following fields:
[Type] [Action 1] [Projected Action 1] [Projected Action 1 Revised] [Action 2]

I want to create a calculated field for [Projected Action 2] that says:

If [Type] is "A" then
if [Action 2] Is NotNull, Null
if [Action 1] is NotNull, [Action 1] + 10 workdays
if [Projected Action 1 Revised] is NotNull, [Projected Action 1 Revised] + 10 workdays
if [Projected Action 1] is NotNull, [Projected Action 1] + 10 workdays

[Code] ....

I would like to keep using nested IIf but I keep running into problems and I thought that there is probably a better way.

View 7 Replies View Related

Queries :: Multi Search Form Not Returning Results

Sep 11, 2014

Multi search wont return results: Obviously I have my table and search form. But have hit a problem that is probably simple to overcome, but for the life of me I cant see it.

The small peice of code I have used = forms]![searchF]![name1] I have also tried Like"*" & forms]![searchF]![name1] & "*" still not working. The qurey accompanying form (searchF) works to displaying searchF form unpopulated which I believe is correct. I should at this stage be able to fill out the one table heading (name1) where the query should return a result in the (searchf) form but it does not return.

The tables, forms and quries, have all been saved and closed and re opened many times

The form (searchF) propeties have been checked and double checked. I have even built a test table but the same things happen as my main table.

View 14 Replies View Related







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