Problems with Parameter Queries!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atiq
    New Member
    • Apr 2007
    • 36

    Problems with Parameter Queries!

    i have a Query where i have Criteria for two fields as the following:

    Field :Date of Incident
    Crirteria: [Forms]![frmSearchStuden t&Date]![cboStartDate] And [Forms]![frmSearchStuden t&Date]![cboEndDate]

    Field: StudentSurname
    Criteria: [Forms]![frmSearchStuden t&Date]![Combo0]

    Occasionally, staff may just want all incidents (records) to be shown for the selected StudentSurname and so, just select the surname and leave the date fields blank.

    i tried the following:
    Field :Date of Incident
    Crirteria: [Forms]![frmSearchStuden t&Date]![cboStartDate] And [Forms]![frmSearchStuden t&Date]![cboEndDate]
    Or: [Forms]![frmSearchStuden t&Date]![cboStartDate] Is Null And [Forms]![frmSearchStuden t&Date]![cboEndDate] Is Null

    Field: StudentSurname
    Criteria: [Forms]![frmSearchStuden t&Date]![Combo0]

    then when i tested this by leaving the date fields blank and selecting a valid student surname it simply returned all incidents (records) for ALL students not the selected one.

    is it possible to achieve this? if so, could someone please help!
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Try this ...

    Field :Date of Incident
    Crirteria: IIf(Not IsNull([Forms]![frmSearchStuden t&Date]![cboStartDate]), [Forms]![frmSearchStuden t&Date]![cboStartDate] And [Forms]![frmSearchStuden t&Date]![cboEndDate])

    Field: StudentSurname
    Criteria: [Forms]![frmSearchStuden t&Date]![Combo0]

    Mary

    Comment

    • atiq
      New Member
      • Apr 2007
      • 36

      #3
      Originally posted by mmccarthy
      Try this ...

      Field :Date of Incident
      Crirteria: IIf(Not IsNull([Forms]![frmSearchStuden t&Date]![cboStartDate]), [Forms]![frmSearchStuden t&Date]![cboStartDate] And [Forms]![frmSearchStuden t&Date]![cboEndDate])

      Field: StudentSurname
      Criteria: [Forms]![frmSearchStuden t&Date]![Combo0]

      Mary

      I tried using this expression but it doesn't work neither does it display any error messages.

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Try this ...

        Field :Date of Incident
        Crirteria: IIf(Not IsNull([Forms]![frmSearchStuden t&Date]![cboStartDate]), BETWEEN [Forms]![frmSearchStuden t&Date]![cboStartDate] AND [Forms]![frmSearchStuden t&Date]![cboEndDate])



        Mary

        Comment

        Working...