Searchabe data in form

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

Guest

I have a form that is created from a table. I would like to have a text box
that a user can enter say an employee id number and the appropriate data is
then displayed for that employee from the table.

Any help is greatly appreciated.

Thanks

deodev
 
Try using an unbound combo box instead. You could popluate the combo
with all possible EmployeeIDs, so there's no way to enter a non-legitimate
number. Limit to list = Yes. Call the combo (ex. FindEmployeeID)

On the AfterUpdate event of the combo...
DoCmd.GoToControl "EmployeeID"
DoCmd.FindRecord FindEmployeeID
hth
Al Camp
 
Much better to use a "navigation" ComboBox where you users can locate an
Employee Record by name. You can also use EmployeeID but you will find that
searching by name is much more friendlier to the users.

If your Form is bound to a Table / Query, you can use the ComboBox Wizard to
create the "navigation" ComboBox with required code for you.
 
Van,

I am not sure how to create a "navigation" combo box. Also, for the
employee there is multiple rows of data I need to display.
Ideally, a person would enter either a name, ID or case number and then
would see all rows on the form based on the info entered.

By the way, your suggestion on my recordset problet works - that is I had to
use "dim myset as DAO.Recordset. I was missing the DAO.

Thanks
 
You can use form filter to filter records at forms.
1 . create 3 textbox as textbox1 textbox2 and textbox3 and set default
vaule as "*"
2. create commandbutton with name find
3. onclick property of command button
PRIVATE SUB COMMAND1_CLICK()
DIM CRITERIA1 AS STRING, CRITERIA2 AS STRING,CRITERIA3 AS STRING
CRITERIA1 = TEXTBOX1
CRITERIA2 = TEXTBOX2
CRITERIA3 = TEXTBOX3
FORMS!FORM1.FORM.FILTER="[ID] LIKE TEXTBOX1 AND [NAME] LIKE CRITERIA2
AND [SURNAME] LIKE CRITERIA3"
FORMS!FORM1.FORM.FILTERON=TRUE
END SUB
4. create another commandbutton with name show all
5. onclick property of commandbutton2
PRIVATE SUB COMMAND2_CLICK()
FORMS!FORM1.FORM.FILTERON=FALSE
END SUB

I hope it will be usefull for you
 
I am trying this code however the dat is not being filtered - I think there
is a problem with

FORMS!FORM1.FORM.FILTER="[ID] LIKE TEXTBOX1 AND [NAME] LIKE CRITERIA2
AND [SURNAME] LIKE CRITERIA3"

I get a message box to enter the value for all the "criteria1"








t t via AccessMonster.com said:
You can use form filter to filter records at forms.
1 . create 3 textbox as textbox1 textbox2 and textbox3 and set default
vaule as "*"
2. create commandbutton with name find
3. onclick property of command button
PRIVATE SUB COMMAND1_CLICK()
DIM CRITERIA1 AS STRING, CRITERIA2 AS STRING,CRITERIA3 AS STRING
CRITERIA1 = TEXTBOX1
CRITERIA2 = TEXTBOX2
CRITERIA3 = TEXTBOX3
FORMS!FORM1.FORM.FILTER="[ID] LIKE TEXTBOX1 AND [NAME] LIKE CRITERIA2
AND [SURNAME] LIKE CRITERIA3"
FORMS!FORM1.FORM.FILTERON=TRUE
END SUB
4. create another commandbutton with name show all
5. onclick property of commandbutton2
PRIVATE SUB COMMAND2_CLICK()
FORMS!FORM1.FORM.FILTERON=FALSE
END SUB

I hope it will be usefull for you
 
The "Navigation" ComboBox navigates to a single Record, usually on a
(single) normal Form View.

It sounds like you are using ContinuousFormView and in this case, you want
to use Filter rather than "navigation".
 
* You also need to set the FilterOn Property to True.

* The Like is a String comparison operator and I think it should always be
used with the wildcard * or ?. Otherwise, it becomes an inefficient =.
Also, I would normally resolve the TextBox to actual value. In addition,
explicit String values must be enclosed by the String delimiter.

For example, if ID is a Numeric Field, you should use:

Forms!Form1.Filter = "[ID] = & Me.Text1

If ID is String:

Forms!Form1.Filter = "[ID] Like ""*" & Me.Text1 & "*"""

Note: to include a double-quote in a double delimited String, you need to
use 2 double-quotes. The above will result in the filter String:

[ID] Like "*ABC*"

where "ABC" is what the user enters in the TextBox. "Text1"

--
HTH
Van T. Dinh
MVP (Access)



deodev said:
I am trying this code however the dat is not being filtered - I think there
is a problem with

FORMS!FORM1.FORM.FILTER="[ID] LIKE TEXTBOX1 AND [NAME] LIKE CRITERIA2
AND [SURNAME] LIKE CRITERIA3"

I get a message box to enter the value for all the "criteria1"








t t via AccessMonster.com said:
You can use form filter to filter records at forms.
1 . create 3 textbox as textbox1 textbox2 and textbox3 and set default
vaule as "*"
2. create commandbutton with name find
3. onclick property of command button
PRIVATE SUB COMMAND1_CLICK()
DIM CRITERIA1 AS STRING, CRITERIA2 AS STRING,CRITERIA3 AS STRING
CRITERIA1 = TEXTBOX1
CRITERIA2 = TEXTBOX2
CRITERIA3 = TEXTBOX3
FORMS!FORM1.FORM.FILTER="[ID] LIKE TEXTBOX1 AND [NAME] LIKE CRITERIA2
AND [SURNAME] LIKE CRITERIA3"
FORMS!FORM1.FORM.FILTERON=TRUE
END SUB
4. create another commandbutton with name show all
5. onclick property of commandbutton2
PRIVATE SUB COMMAND2_CLICK()
FORMS!FORM1.FORM.FILTERON=FALSE
END SUB

I hope it will be usefull for you
 
Back
Top