Results 1 to 9 of 9
  1. #1
    zy0n1c is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    AL
    Posts
    21

    Unhappy SQL statement returning ALL fields in query/report - Query works otherwise.

    So, I've got my multi-state query working, I've got my multi-checkbox query working, but when I add a 2nd checkbox to the statement below, it shows a query and/or report with ALL fields showing in a horrible layout/design and the relevent data for this report isn't even listed. I believe the problem is due to SELECT EMployeeDB.* -- the asterisk being a wildcard seems like it's telling the query to select ALL the fields. If I remove this part of the statement, I get prompts for the primary ID, firstname, lastname, etc. When nothing is entered into these prompts, they continue into an error " Microsoft Access can't find the field 'EmployeeDB.[Street Address 1]' referred to in your expression. You may have misspelled the field name, or the field may have been renamed or deleted.



    Code:
    SELECT EmployeeDB.[First Name], EmployeeDB.[Last Name], EmployeeDB.State, EmployeeDB.[Phone Number 1], EmployeeDB.[Phone Number 2], EmployeeDB.[Basic+], EmployeeDB.TWIC, EmployeeDB.HAZWOPER, EmployeeDB.Hydroblasting, EmployeeDB.[Scaffold Builder], EmployeeDB.[Confined Spaces], EmployeeDB.[OSHA 10], EmployeeDB.[OSHA 40], EmployeeDB.[CDL w/VAC], EmployeeDB.[CDL (standard)], EmployeeDB.[Valid Driver's License], EmployeeDB.[Job Types], EmployeeDB.[Site Specific Training 1], EmployeeDB.[Site Specific Training 2], EmployeeDB.[Site Specific Training 3], EmployeeDB.[Site Specific Training 4], EmployeeDB.[Site Specific Training 5], EmployeeDB.[Site Specific Training 6], EmployeeDB.[Eligible for Rehire], EmployeeDB.Status, EmployeeDB.*
    FROM EmployeeDB
    WHERE (((EmployeeDB.State) Is Null Or (EmployeeDB.State)=[Forms]![EmployeeListMenu]![ComboState1] Or ((EmployeeDB.State) Is Null Or (EmployeeDB.State)=[Forms]![EmployeeListMenu]![ComboState2]) Or ((EmployeeDB.State) Is Null Or (EmployeeDB.State)=[Forms]![EmployeeListMenu]![ComboState3]) Or ((EmployeeDB.State) Is Null Or (EmployeeDB.State)=[Forms]![EmployeeListMenu]![ComboState4])) AND ((EmployeeDB.[Basic+]) Like IIf([forms]![EmployeeListMenu]![CheckBasicPlus],True,"*")) AND ((EmployeeDB.HAZWOPER) Like IIf([forms]![EmployeeListMenu]![CheckHAZWOPER],True,"*")));

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Remove EmployeeDB.* as you already have lots of fields from that table.
    Alternatively, remove all the other fields from that table and just use the EmployeeDB.*
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    zy0n1c is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    AL
    Posts
    21
    Either way, with EmployeeDB.* and with all the fields WITHOUT EmployeeDB.* - I get an output of every field.

    Click image for larger version. 

Name:	All Fields.png 
Views:	13 
Size:	32.4 KB 
ID:	33862

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    There is an option in the query designer properties to "Output All Fields" - I would check that setting
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    zy0n1c is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    AL
    Posts
    21
    Output All Fields is set to "No"

  6. #6
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    That's a report view - you would have to explicitly remove the fields from the report for them to disappear from the report view.
    Simply removing them from the query won't stop the report asking for the field in the report design controls sources
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    zy0n1c is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    AL
    Posts
    21
    ...I don't know what happened. I have that exact report printed out on my desk from yesterday from before I added the 2nd checkbox. It has only the fields I designed the report to have. I spent an hour making that report look "pretty." yesterday. Now, when I open my database from yesterday (I save a fresh copy each morning and save it all throughout the afternoon), all those fields are showing up in the design view that were NOT there yesterday.

    I guess I'm going to start over from scratch and try to work this out from the beginning. I hate recreating these reports....

  8. #8
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Watch out for this-- If you have a table or query highlighted in the Nav Pane, and on the ribbon you click Create>Report, a report will be created with ALL the fields in that query or table. If you close the report, Access will ask if you want to save it and give it a name.
    If you specify an existing report name or take the default, it will overwrite any existing report with that name. Maybe this gotcha.

  9. #9
    zy0n1c is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    AL
    Posts
    21
    I started from scratch and decided to get my query working properly before even bothering with the report. Going to post a new thread with my new wonderful issue!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 09-26-2016, 10:36 PM
  2. Replies: 3
    Last Post: 11-20-2014, 12:18 PM
  3. Query Not Returning Null Fields
    By mgmirvine in forum Queries
    Replies: 2
    Last Post: 10-28-2011, 06:15 PM
  4. Query returning fields not chosen
    By cam2era in forum Queries
    Replies: 5
    Last Post: 03-23-2011, 11:43 AM
  5. Replies: 2
    Last Post: 03-23-2011, 11:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums