Results 1 to 13 of 13
  1. #1
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215

    IS NULL in criteria question

    Hi,



    I have this particular field with values "YES" or Blank

    Click image for larger version. 

Name:	Question.jpg 
Views:	17 
Size:	132.0 KB 
ID:	17598
    I have it set up so that now all I need is that Criteria specifies whether an unbound text box on another form was filled out or not. If it was, the Null field values dissapear and I am only left with the fields with "YES" values. Also, if the field was not filled out, then nothing happens and the records remain.

    I assume this entails an iif statement or something, but I can't seem to get it to work. I'd prefer working with just the criteria field btw and not VBA.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Can you show us the SQL view of the query you have?

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Try:
    IIf(IsNull(Forms!formname!textboxname), "*" Or Is Null, "Yes")

    It would be better if the Exp1 returned something in every record, like N/A or None or No.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    SELECT MAIN_T.REFID, MAIN_T.AgenciesMain, MAIN_T.SourceMain, MAIN_T.AnnouncedMain, MAIN_T.EffectiveMain, MAIN_T.UpdatesMain, MAIN_T.ContentsMain, MAIN_T.EntitiesMain, MAIN_T.Action, MAIN_T.Summary, IIf(DatePart("ww",[AnnouncedMain])=DatePart("ww",[Forms]![Search_F]![ANNOUNCED]),"YES","") AS Expr1FROM MAIN_T
    WHERE (((MAIN_T.UpdatesMain) Like "*" & [forms]![Search_F]![UPDATE] & "*") AND ((MAIN_T.ContentsMain) Like "*" & [forms]![Search_F]![CONTENT] & "*") AND ((MAIN_T.EntitiesMain.Value) Like "*" & [forms]![Search_F]![ENTITY] & "*") AND ((MAIN_T.AgenciesMain.Value) Like "*" & [forms]![Search_F]![AGENCY] & "*")) OR (((MAIN_T.AgenciesMain.Value)=[forms]![Search_F]![ANNOUNCED]));

    Basically, I set up a field to test whether something was true or not, if it was - YES - if not - Blank. Now, all I need is to know whether or not someone inputted something into a particular text box on another form - in this case [forms]![Search_F]![ANNOUNCED]. If they did, then the YES's stay and the blanks disappear.

  5. #5
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    June7.. that worked. Why did that work?

    that's like saying

    If IsNull(forms![form][whatever]) Then
    "*" OR IS NULL
    Else
    "YES"
    End If

    Kind of trying to figure out the logic behind the statements "*" OR IS NULL and just the "YES"

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    "*" is wildcard but Nulls are ignored so those records would not return, therefore the Or Is Null captures the Null records. If every record had a string value, could simplify:

    IIf(IsNull(Forms!formname!textboxname), "*", "Yes")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    Oh, Okay. I get it. Thanks!

  8. #8
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    How do you specify that this thread was solved?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Thread Tools dropdown above first post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    I'm not sure. I'm running into another problem.

    All I want to do is check to see if a user inputted date falls within a certain week. If it does, I show all the records within that week.

    So, if a user inputs data for 06/26/2014. All the records from that given week show up.

    I know how to calculate the week number given DatePart("ww", forms![Search][whatever]). But I want to run all the other dates against that and then display only the other dates that fall into that week.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    WHERE DatePart("ww", [fieldname]) = DatePart("ww", Forms![Search][whatever])

    However, if multiple years in data:

    WHERE Year([fieldname]) & DatePart("ww", [fieldname]) = Year(Forms![Search][whatever]) & DatePart("ww", Forms![Search][whatever])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    What happens if the search field is blank?

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Try it and let me know.

    I don't use dynamic parameterized queries. I use VBA to build filter criteria and apply to form or report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Simple "Or is null" Criteria question
    By floyd in forum Queries
    Replies: 2
    Last Post: 11-22-2013, 10:05 AM
  2. Criteria not equal to and null
    By andy-29 in forum Access
    Replies: 7
    Last Post: 11-21-2012, 06:16 PM
  3. A Null question
    By itm in forum Database Design
    Replies: 3
    Last Post: 08-22-2012, 01:33 PM
  4. Query criteria with values and null
    By robsworld78 in forum Queries
    Replies: 13
    Last Post: 03-27-2012, 05:44 AM
  5. Replies: 1
    Last Post: 02-23-2012, 02:27 PM

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