Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Databases > Microsoft Access

Sponsored Links

Discuss "Query Parameter" in the Microsoft Access forum.

Microsoft Access - Microsoft Access is a database for small to medium applications. Learn tips and tricks and best database practices here.


Closed Thread
 
LinkBack Thread Tools Display Modes
  #1  
Old June 10th, 2008, 12:57 PM
Barn Newbie
 
Join Date: Apr 2008
Location: Lake County, IL
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
alansidman is an unknown quantity at this point
Default Query Parameter

Ben answered this on the other side of the world, but my PC locks up when I try to access the thread. Ben suggested that I add Nz(tblTermsNDA.ndaSpec,"") AS Specialist. I amended the query and put "MT" as the response for the null field. The expected results of a record with the field ndaSpec as Null does not appear in the query results with MT as the specialist. Thoughts on this??



Queries - Parameter Setting in Query

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

In a query I have developed, there is a field for Specialists. The end user has the option of selecting the particular specialist that they would like reports for by selecting the first four letters of the specialists last name and *. If the EU wishes to obtain the report for all specialists, he enters* and the enter key. The query operates as defined unless a specialists name is absent. In that case, the record is omitted from the report. I would like those records to appear when the EU selects all.

Here is the SQL for the query:
SELECT tblTermsNDA.ndaID AS ID, tblTermsNDA.ndaClient AS Client, tblTermsNDA.ndaReqDte AS RequestDate, tblTermsNDA.ndaSpec AS Specialist,
FROM tblTermsNDA
HAVING (((tblTermsNDA.ndaSpec) Like [Enter * for all or first four letters of last name and *])


What am I missing here to make it all inclusive.
Sponsored Links
  #2  
Old June 10th, 2008, 01:08 PM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 176
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

You didn't say what it DID return, but I'm going to guess that the field is spaces rather than actually NULL. Try
Code:
 Select * from tblTermsNDA where ndaSpec IS NULL
just to make sure.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
  #3  
Old June 10th, 2008, 01:18 PM
Barn Newbie
 
Join Date: Apr 2008
Location: Lake County, IL
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
alansidman is an unknown quantity at this point
Default

Thanks Wolffy. To answer your question, it did not return any results for the record which had a blank (null) Spec Field. I am pretty sure that the field was not spaces because I went to the record on the form and highlighted the control and then pressed the delete key and not the space bar, in order to test it. I will add your line of code to the sql statement and let you know what happens.


Alan
  #4  
Old June 10th, 2008, 01:50 PM
Barn Newbie
 
Join Date: Apr 2008
Location: Lake County, IL
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
alansidman is an unknown quantity at this point
Default

Another question regarding this. If I add the suggested code to the SQL statement as noted by Wolffy, what happens if the field is not Null. It looks like the amended code would only select from the table if the Spec field was null.

Alan
  #5  
Old June 10th, 2008, 01:53 PM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 176
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Wasn't suggesting that you change you query -- that one I supplied is a one off just to confirm the field is indeed null rather than spaces or an empty string -- a sanity check.
  #6  
Old June 10th, 2008, 02:10 PM
Barn Newbie
 
Join Date: Apr 2008
Location: Lake County, IL
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 1
alansidman is an unknown quantity at this point
Default

My mis understanding. In the interim, I have solved the issue. I took Ben's suggestion and added an Nz function to the SQL with a value if null as "MT". I further added an "Or" criteria for the Spec field which said "Is Null"
Voila!!! Results as anticipated. All Null Spec fields were returned with MT in it.
The fields can now be corrected by the Specialists.

Thanks for your time.

Alan
Closed Thread

  DeveloperBarn Forums > Databases > Microsoft Access

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -4. The time now is 02:42 PM.



Content Relevant URLs by vBSEO 3.2.0