datasheet form dynamic filter

  • Thread starter Thread starter Ren
  • Start date Start date
R

Ren

I created a datasheet form using the wizard. I want an input box (for
the key field) so that only the records appear that match what the
user has typed so far. In other words, the input box causes a dynamic
filter based on the change event (or something like that). For
example, let's say there are 5 records that start with the letter B
like so:

ban
bed
beat
bit
bite

When the user types a b as the first letter, all the records that
begin with b are shown in the datasheet view. If the user then adds
the letter e, only the records with the key field of bed and beat are
shown. If the user backspaces, all the records with b are shown. If
the user adds an i after the b, only the records with the key field of
bit and bite are shown.

Thanks in advance.
 
it is difficult to achieve this in datasheet view
method 1
tell users to right-click on the field in datasheet view, and then in the menu, on the "filter" option, type in "Like be*" - then that will display all records where the field starts "be
method 2
change the form to continuous form view. that way, you can have a visible form header. in there, put a text control box, let's call it [txtFilter]. you may need to add another control after that one so that the focus can move from that control. then, add an AfterUpdate event procedure to that control
the code in the form's module would read

If IsNull(Me!txtFilter) The
Me.Filter="
Me.FilterOn=Fals
Els
Me.Filter="[Field1] Like """ & me!txtFilter & "*""
Me.FilterOn=Tru
End I

replace the [Field1] with the name of the field you're searching fo
whenever the user writes something in the box and moves focus (by pressing tab, e.g.), the form should filte
 
Back
Top