Results 1 to 11 of 11
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    ehhhh Getting multiple criteria.. I should know this by now I know

    Code:
    DoCmd.OpenForm "frmSchools", , , "SchoolTypeID = 2 or 9 or 10" And Not IsNull(CallBackDate) And TourOrganiserID = Forms!frmSwitchStaff!txtTele
    trying to get the form to open all SchoolyType with id's 2, or 9 or 10


    DoCmd.OpenForm "frmSchools", , , "SchoolTypeID =" & 2 & 9 & 10" & And Not IsNull(CallBackDate)" & And TourOrganiserID = Forms!frmSwitchStaff!txtTele"

    or something like this?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    "(SchoolTypeID = 2 Or SchoolTypeID = 9 Or SchoolTypeID = 10) And Not IsNull(CallBackDate) And TourOrganiserID=" & Forms!frmSwitchStaff!txtTele
    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.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Thanking you!

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    "(SchoolTypeID = 2 Or SchoolTypeID = 9 Or SchoolTypeID = 10) And Not IsNull(CallBackDate) And TourOrganiserID=" & Forms!frmSwitchStaff!txtTele
    When you have something like above and you want to add a field with a date criteria that is not on the form (a set date) why would I get a datatype mismatch?

    "(SchoolTypeID = 2 Or SchoolTypeID = 9 Or SchoolTypeID = 10) And Not IsNull(CallBackDate) And TourOrganiserID=" & Forms!frmSwitchStaff!txtTele

    but now I want to add CatalogueLabelPrinted (date field) within a specific date 1/5/2013

    I know that dates have to be within hash like so #1/5/2013#

    I guess that CatalogueLabelPrinted requires "CatalogueLabelPrinted >"

    however joining it to the above criteria so that the form opens with that isn't working.

    I'm trying to wrap my head around concatenation and using and but I don't quite get it on how to understand to do it freely whenever.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    CatalogueLabelPrinted is a date/time type field? It is in the form RecordSource?

    "(SchoolTypeID = 2 Or SchoolTypeID = 9 Or SchoolTypeID = 10) And Not IsNull(CallBackDate) AND CatalogueLabelPrinted>#1/5/2013# And TourOrganiserID=" & Forms!frmSwitchStaff!txtTele
    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.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    DoCmd.OpenForm "frmSchoolsCatalogues", , , "(SchoolTypeID = 2 Or SchoolTypeID = 9 Or SchoolTypeID = 10) And Not IsNull(CallBackDate) AND CatalogueLabelPrinted> #1/5/2013# And TourOrganiserID=" & Forms!frmSwitchStaff!txtTele

    Works!
    questions

    why when doing this do you never use say

    "(SchoolTypeID = 2 Or SchoolTypeID = 9 Or SchoolTypeID = 10) And Not IsNull(CallBackDate) & "AND CatalogueLabelPrinted>" & #1/5/2013# & "AND TourOrganiserID=" & Forms!frmSwitchStaff!txtTele

    I'm not clear as to where you should and shouldn't use "

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You have an unnecessary & " in the expression. The date can be concatenated but only useful if it is a reference to user input, like with TourOrganiserID.

    All literal text (non dynamic, non variable parts) go within quote marks. Concatenate variables.
    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.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    You have an unnecessary & " in the expression. The date can be concatenated but only useful if it is a reference to user input, like with TourOrganiserID.

    All literal text (non dynamic, non variable parts) go within quote marks. Concatenate variables.
    what happens if the date field is null? as in CatalogueLabelPrinted>#1/5/2013#

    could you just add
    CatalogueLabelPrinted>#1/5/2013# or null

    ?

  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,770
    You want to return record if the CatalogueLabelPrinted field has no data?

    Try:

    CatalogueLabelPrinted>#1/5/2013# Or CatalogueLabelPrinted Is Null

    or

    Nz(CatalogLabelPrinted,#12/31/2099#)>#1/5/2013#
    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
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Nz(CatalogueLabelPrinted,#12/31/1888#)<=#1/5/2013#

    Thanks I added that one and it works like a charm. Not sure if it is picking up the nulls yet, hoping it does.

  11. #11
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Seems to

    Please nobody ask me why I used 1888. It's nothing significant to me. It was only the year I was born.

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

Similar Threads

  1. Replies: 2
    Last Post: 04-10-2013, 03:54 PM
  2. Sum IIf Multiple Criteria
    By RogerC in forum Reports
    Replies: 6
    Last Post: 01-29-2013, 04:43 PM
  3. Replies: 7
    Last Post: 01-02-2013, 11:23 PM
  4. If Then Else Multiple Criteria
    By GrayWolf in forum Programming
    Replies: 5
    Last Post: 04-12-2012, 07:27 PM
  5. Replies: 1
    Last Post: 07-13-2011, 11:00 AM

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