Share via

Create filter with vba using Is Null

Anonymous
2015-04-23T20:45:03+00:00

Me.Filter = DateSent Is Null

Me.FilterOn = True

Error: Object required. Code is event procedure on the form containing the field DateSent

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2015-04-24T15:54:22+00:00

Aha! This makes more sense now. 

Since the button code is on frmMatterScheduleSelection, the Me. refers to that form, not to the form you're trying to open.

Try changing the code to

Private Sub cmdMatterSchedule_Click()

On Error GoTo Err

    DoCmd.OpenForm "frmMatterSchedule", _

         WhereCondition:="[DateSent] IS NULL"

    DoCmd.GoToControl ("Hdr")

Exit_Err:

    Exit Sub

Err:

    MsgBox Err.Description, , "Sorry"

    Resume Exit_Err

End Sub

 and omit the Filter code altogether.

You may also need to move the GoToControl line to the Load event of frmMatterSchedule.

Was this answer helpful?

0 comments No comments

12 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-04-23T22:46:59+00:00

    No go, John. Gives the Enter Parameter Value dialog box.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-04-23T22:33:14+00:00

    I'd try

    Me.Filter = "[DateSent] IS NULL"

    with the brackets; this is assuming that DateSent is in fact a field in the form's Recordsource. This kind of glitch is one reason to consider using control names different that the control's bound field (name the textbox txtDateSent say) to remove the ambiguity.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2015-04-23T21:37:16+00:00

    Hi Scott,

    I tried that...it gives me this:

    Does it have something to do with the fact that both the txtbox and control source are called DateSent?

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,830 Reputation points Volunteer Moderator
    2015-04-23T20:48:05+00:00

    Me.Filter = "DateSent = Null"

    or

    Me.Filter = "IsNull(DateSent)"

    The Filter property is a text string.

    Was this answer helpful?

    0 comments No comments