Form filter on load

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

For some reason, the following code in my sub form's On Load Event simply
doesn't work:

Private Sub Form_Load()
Me.Filter = [Status] <> "*closed*"
FilterOn = True
DoCmd.Requery
End Sub

Any ideas?
 
Bdavis said:
For some reason, the following code in my sub form's On Load Event
simply doesn't work:

Private Sub Form_Load()
Me.Filter = [Status] <> "*closed*"
FilterOn = True
DoCmd.Requery
End Sub

Any ideas?

The filter property is a String and therefore needs to be quotes.
 
Try changing the <> to Not Like

Private Sub Form_Load()
Me.Filter = [Status] Not Like "*closed*"
FilterOn = True
DoCmd.Requery
End Sub
 
Sorry Rick... what am I missing? It is in quotes.

Rick Brandt said:
Bdavis said:
For some reason, the following code in my sub form's On Load Event
simply doesn't work:

Private Sub Form_Load()
Me.Filter = [Status] <> "*closed*"
FilterOn = True
DoCmd.Requery
End Sub

Any ideas?

The filter property is a String and therefore needs to be quotes.
 
Ofer,

It didn't like the word Like

Ofer said:
Try changing the <> to Not Like

Private Sub Form_Load()
Me.Filter = [Status] Not Like "*closed*"
FilterOn = True
DoCmd.Requery
End Sub

--
I hope that helped
Good Luck


Bdavis said:
For some reason, the following code in my sub form's On Load Event simply
doesn't work:

Private Sub Form_Load()
Me.Filter = [Status] <> "*closed*"
FilterOn = True
DoCmd.Requery
End Sub

Any ideas?
 
Try this

' If you dont want the records that the word closed apear in
Me.Filter = "[Status] not like '*closed*'"
FilterOn = True

Or
' If you dont want the records that the word *closed* exact match apear in
Me.Filter = "[Status] <> '*closed*'"
FilterOn = True

There is no need for the requery

--
I hope that helped
Good Luck


Bdavis said:
Ofer,

It didn't like the word Like

Ofer said:
Try changing the <> to Not Like

Private Sub Form_Load()
Me.Filter = [Status] Not Like "*closed*"
FilterOn = True
DoCmd.Requery
End Sub

--
I hope that helped
Good Luck


Bdavis said:
For some reason, the following code in my sub form's On Load Event simply
doesn't work:

Private Sub Form_Load()
Me.Filter = [Status] <> "*closed*"
FilterOn = True
DoCmd.Requery
End Sub

Any ideas?
 
Bdavis said:
Sorry Rick... what am I missing? It is in quotes.

Not just the criteria value, the whole thing...

Me.Filter = "[Status] <> '*closed*'"
FilterOn = True
 
Back
Top