J
Jane Pulley
Hello group! I would like to use a txtBox to filter form
by employee number. What code do I need to accomplish this?
Thank You,
JP
by employee number. What code do I need to accomplish this?
Thank You,
JP
Set the form's filter property to the field and value, then turn itHello group! I would like to use a txtBox to filter form
by employee number. What code do I need to accomplish this?
Jim, this won't work. I forgot to tell you I have an-----Original Message-----
Set the form's filter property to the field and value, then turn it
on.
Me.Filter = "EmployeeNum = " & Me.txtBox
Me.FilterOn = True
To turn the filter off set it to an empty string.
Me.Filter = ""
You don't need to turn it off.
- Jim
.
Jim, this won't work. I forgot to tell you I have an
option group, containing two option buttons. One is for
Employee name, other is for employee number. I get the
employee name to work fine, it's the number I cannot get
it to search right. When I use this code it takes me to
a number that isn't related what so ever. grr!
JP
-----Original Message-----
Well, what is in the textbox? Actually I would think a combo box with
a Row Source of employees would be a better approach.
In what event are you putting the code, and what is the code?
There is nothing wrong with the approach.
- Jim
.
-----Original Message-----
Well, what is in the textbox? Actually I would think a combo box with
a Row Source of employees would be a better approach.
In what event are you putting the code, and what is the code?
There is nothing wrong with the approach.
- Jim
.
Here is my code. If you know of a better way with a
combo box please tell me. Thank you!
Private Sub txtFind_AfterUpdate()
If fraFilter = optEmpName.OptionValue Then
If Me.Dirty Then
Me.Dirty = False
End If
If IsNull(Me.txtFind) Then
Me.FilterOn = False
Else
Me.Filter = "[txtEmpName] Like """ &
Me.txtFind & "*"""
Me.FilterOn = True
End If
End If
If fraFilter = optEmpNumber.OptionValue Then
If Me.Dirty Then
Me.Dirty = False
End If
If IsNull(Me.txtFind) Then
Me.FilterOn = False
Else
Me.Filter = "[txtEmpNumber]=" & Me.txtFind
Me.FilterOn = True
End If
End If
End Sub