473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Query Criteria Error:

Hi All,

I am using a query to pull records of all files in a given location. The file location is a dropdown list of possible locations: Pending Approval, Pending Correction, Mailed, Paid.

I would like to be able to run a report of all files "Pending Approval". I created the Query with the Criteria [FileLocation]="Pending Approval" (exactly as it appears on the data table). If a file's location has not been updated it works fine, but I've noticed that if a file's location has been changed it will not appear on the report.

Example: The file starts out "Pending Approval' and appears on the report as it should. The approver requests a correction, so I update the location to "Pending Correction", and the file drops off of the report as it should. I resubmit the file for approval once it has been corrected, and update the file's location to "Pending Approval" but after this change the file will not appear on the report.

I have no idea why.

Any thoughts?

Thanks!

~Vicki
Aug 18 '09 #1

✓ answered by ajalwaysus

OK I think that is your issue, you bound the combo box to "1" which refers to the ID not the actual text. The reason you are seeing the text in the table is because you probably set it up to be a lookup, and if that is the case, the field will look up the text value and display that, but it will be storing the ID in the table not the text.

So test this code and let me know if your missing record shows up:
Expand|Select|Wrap|Line Numbers
  1. SELECT INVOICEDATA.ProjectManager, INVOICEDATA.ToCustSvc, INVOICEDATA.CustomerNumbers, [CUSTOMER NUMBERS AS400].CustomerNameAS400, INVOICEDATA.InvoiceNumber, INVOICEDATA.OrderNumber, INVOICEDATA.InvoiceDate, INVOICEDATA.ItemTotal, INVOICEDATA.FreightTotal, INVOICEDATA.SalesTaxTotal, [ItemTotal]+[FreightTotal]+[SalesTaxTotal] AS InvoiceTotal, INVOICEDATA.FileLocation, DateDiff("d",[INVOICEDATA].[ToCustSvc],Date()) AS DaysPending, INVOICEDATA.Comments
  2. FROM [CUSTOMER NUMBERS AS400] INNER JOIN INVOICEDATA ON [CUSTOMER NUMBERS AS400].CustomerNumberAS400=INVOICEDATA.CustomerNumbers
  3. WHERE (((INVOICEDATA.FileLocation)=2))
  4. ORDER BY INVOICEDATA.ProjectManager;
  5.  
I noticed you placed the number 2 in quotes, which I did not.

-AJ

11 2071
ajalwaysus
266 Expert 100+
Sounds like you may be running off an old value, or something as simple as a typo. Please post the code you are using, to help understand how you are executing the report.

-AJ
Aug 18 '09 #2
Thanks AJ!

The code is being generated by Access 2007:
----------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. SELECT INVOICEDATA.ProjectManager, INVOICEDATA.ToCustSvc, INVOICEDATA.CustomerNumbers, [CUSTOMER NUMBERS AS400].CustomerNameAS400, INVOICEDATA.InvoiceNumber, INVOICEDATA.OrderNumber, INVOICEDATA.InvoiceDate, INVOICEDATA.ItemTotal, INVOICEDATA.FreightTotal, INVOICEDATA.SalesTaxTotal, [ItemTotal]+[FreightTotal]+[SalesTaxTotal] AS InvoiceTotal, INVOICEDATA.FileLocation, DateDiff("d",[INVOICEDATA].[ToCustSvc],Date()) AS DaysPending, INVOICEDATA.Comments
  2. FROM [CUSTOMER NUMBERS AS400] INNER JOIN INVOICEDATA ON [CUSTOMER NUMBERS AS400].CustomerNumberAS400=INVOICEDATA.CustomerNumbers
  3. WHERE (((INVOICEDATA.FileLocation)="PENDING PROJECT MANAGER APPROVAL"))
  4. ORDER BY INVOICEDATA.ProjectManager;
--------------------------------------------------------------------

The field INVOICEDATA.FileLocation comes from a dropdown list - so it won't let me typo when I enter the information in that field. It only presents a problem if I have changed the value of INVOICEDATA.FileLocation from anything else to "PENDING PROJECT MANAGER APPROVAL". If it starts out as "PENDING PROJECT MANAGER APPROVAL" it works perfectly.

Rassin' Frassin' Computers! ;)

Thanks again!

~Vicki
Aug 18 '09 #3
ajalwaysus
266 Expert 100+
OK, just to make sure I understand so far, the code you gave me is the record source of the report?

If that is the case, 2 things I want to run by you:
1. Are you setting the initial value (on creation) of the record using the same combo box as when you change it from one value to another? (Check the bound column)
2. if 1 is a "Yes", then are you updating the same record, or creating a different record as you update the INVOICEDATA.FILELOCATION field.

-AJ

P.S. for future reference, you should try to post code in the
Expand|Select|Wrap|Line Numbers
  1.  CODE
window, it looks like a pound sign above when posting. No Worries.
Aug 18 '09 #4
I'll figure out that code posting thing next. :)

I always use the same combo box for file location (bound column = 1), and avoid creating new records whenever possible. I don't need a historical list of the file's location, so I just change it right there on the original record.

Thanks!

~Vicki :)
Aug 18 '09 #5
ajalwaysus
266 Expert 100+
Ok sounds normal so far. So my next question to you is, could you post the rowsource code for the FileLocation combobox? Because I'm just wondering if you are storing the actual text "PENDING PROJECT MANAGER APPROVAL" in your table or do you use an ID.

Sorry haven't figured it out yet,
-AJ
Aug 18 '09 #6
Expand|Select|Wrap|Line Numbers
  1. SELECT [InvoiceDataLocations].[ID], [InvoiceDataLocations].[FileLocations] FROM InvoiceDataLocations ORDER BY [FileLocations]; 
It references an ID... but the actual text appears in the INVOICEDATA data table.

Also, if I use the ID number for "PENDING PROJECT MANAGER APPROVAL" (in this case "2") the query comes up blank.

No worries on not solving the problem yet. I've been playing with it for hours now and it's still vexing me. I appreciate you taking the time!

Thanks!

~Vicki :)
Aug 18 '09 #7
ajalwaysus
266 Expert 100+
OK I think that is your issue, you bound the combo box to "1" which refers to the ID not the actual text. The reason you are seeing the text in the table is because you probably set it up to be a lookup, and if that is the case, the field will look up the text value and display that, but it will be storing the ID in the table not the text.

So test this code and let me know if your missing record shows up:
Expand|Select|Wrap|Line Numbers
  1. SELECT INVOICEDATA.ProjectManager, INVOICEDATA.ToCustSvc, INVOICEDATA.CustomerNumbers, [CUSTOMER NUMBERS AS400].CustomerNameAS400, INVOICEDATA.InvoiceNumber, INVOICEDATA.OrderNumber, INVOICEDATA.InvoiceDate, INVOICEDATA.ItemTotal, INVOICEDATA.FreightTotal, INVOICEDATA.SalesTaxTotal, [ItemTotal]+[FreightTotal]+[SalesTaxTotal] AS InvoiceTotal, INVOICEDATA.FileLocation, DateDiff("d",[INVOICEDATA].[ToCustSvc],Date()) AS DaysPending, INVOICEDATA.Comments
  2. FROM [CUSTOMER NUMBERS AS400] INNER JOIN INVOICEDATA ON [CUSTOMER NUMBERS AS400].CustomerNumberAS400=INVOICEDATA.CustomerNumbers
  3. WHERE (((INVOICEDATA.FileLocation)=2))
  4. ORDER BY INVOICEDATA.ProjectManager;
  5.  
I noticed you placed the number 2 in quotes, which I did not.

-AJ
Aug 18 '09 #8
NeoPa
32,556 Expert Mod 16PB
Nice going AJ.

Another point to consider is :
Have you requeried the data in the report?

A Refresh will only update existing records. The report would determine that the record is no longer matching the criteria, thus drop it. A record which wasn't previously in the list would not suddenly show up however, unless Requery (instead) is used.

Numeric literal values in SQL are used without quotes. Strings are enclosed in quotes, and dates are enclosed in hashes (#). See Quotes (') and Double-Quotes (") - Where and When to use them and Literal DateTimes and Their Delimiters (#).

That is to say, if INVOICEDATA.FileLocation is a numeric field, then there should be no quotes, yet if it is a string field, then they are required.
Aug 18 '09 #9
Thanks AJ and Neo!

I only used the quotes around the 2 in typing my reply. :)

When I used 2 as my criteria the report had nothing on it at all.

I decided to delete the field from my query and re-add it, and for some reason that worked. I'm not quite sure why, but it all behaves normally now. Go fig.

And yes, the report triggers the query to run automatically, so I always have the most up to date information possible on the report.

Thanks to you both for all of your help!

~Vicki
Aug 19 '09 #10
NeoPa
32,556 Expert Mod 16PB
A pleasure to be of help Vicki :)
Aug 20 '09 #11
ajalwaysus
266 Expert 100+
Glad to help. =)

-AJ
Aug 20 '09 #12

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

Similar topics

0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
4
by: paii, Ron | last post by:
I am trying to use the following "Elookup" function on a query that gets 2 parameters from an open form. ?eLookup("", "qryWOLPCMatEst") Returns the following error. Too few parameters....
5
by: SuffrinMick | last post by:
Hello - I'm a newbie to coding! I'm working on an access 2000 database which has three tables: tblContacts - A list of customer contacts. tblOrgTypes - A list of organisational types....
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
0
by: MLH | last post by:
I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string...
3
by: MLH | last post by:
Am repeating question with different subject heading, perhaps stating more clearly my problem... I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
2
by: ecoulson123 | last post by:
I am using Access 2000. I am trying to summarize numeric data from a large database. The problem is that I need the summarization functions to ignore "junk" data, defined in a couple ways. ...
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
17
by: sharsy | last post by:
Hello guys, I would like some help in generating query criteria that will identify credit cards that have expired on an access database. The specific Field is formatted with a Data Type of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.