Search button

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

Guest

Hi,

I want to build one search button on my form. Above the button got one text
box where user have to enter the value into the textbox and click search
button to find the value from my table. Can anyone assist me on the coding
for the command button so that it can search the value entered on the text
box from my table? Your help is very much appreciated. Thanks in advance.

Izrul
 
See:
Using a Combo Box to Find Records
at:
http://allenbrowne.com/ser-03.html
Although the article talks about a combo box, you can use the same code for
a text box. And you can use the Click event of a button instead of the
AfterUpdate event of the text box if you prefer.

If you want to give the user the choice of which field to search in, see:
Find as you type - Filter forms with each keystroke
at:
http://allenbrowne.com/AppFindAsUType.html
This one is very simple to implement, i.e. the code is just copy'n'paste
with no changes needed, and you can use it on any form.
 
On Mon, 27 Nov 2006 11:34:34 +0800, "Allen Browne"

<snip>

|If you want to give the user the choice of which field to search in, see:
| Find as you type - Filter forms with each keystroke
|at:
| http://allenbrowne.com/AppFindAsUType.html
|This one is very simple to implement, i.e. the code is just copy'n'paste
|with no changes needed, and you can use it on any form.

Sorry to jump in here. But I just wanted to say thanks. That one
is a lovely solution for a problem I had too!
I am using this on a form to find records for editing. Is there a
way to:

a/ Hide the "start, next, end" record navigation controls at the
bottom of a form.

b/ Force the form to open with a blank record (at the moment, it
opens with the first record showing).

c/ Put a "confirm or cancel" dialog for the user to click AFTER
any updates to a record.
 
Re (a), set the form's Navigation Buttons property to No.

Re (b), set the form's Data Entry property to Yes.

Re (c), use the BeforeUpdate event of the form. Steps:

1. Set the BeforeUpdate property of the *form* (not control) to:
[Event Procedure]

2. Click the Build button beside this.
Access opens the code window.

3. Set up the code like this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save?", vbYesNo) = vbNo Then
Cancel = True
Me.Undo
End If
End Sub
 
On Mon, 27 Nov 2006 16:41:13 +0800, "Allen Browne"

|Re (a), set the form's Navigation Buttons property to No.
|
|Re (b), set the form's Data Entry property to Yes.
|
|Re (c), use the BeforeUpdate event of the form. Steps:
|
|1. Set the BeforeUpdate property of the *form* (not control) to:
| [Event Procedure]
|
|2. Click the Build button beside this.
|Access opens the code window.
|
|3. Set up the code like this:
| Private Sub Form_BeforeUpdate(Cancel As Integer)
| If MsgBox("Save?", vbYesNo) = vbNo Then
| Cancel = True
| Me.Undo
| End If
| End Sub

Thank you Allen. Sorry about "a" by the way. I must have had a
mind-block!

Couple of problems during use:
Having set data entry to 'yes', I get a blank, grey form with
just the search controls from ajbFindAsUType. However, the search
doesn't work anymore. It actually seems that the only way I can
get a record to show is to select the filter search combo box to
a field that only contains data from one record. Wierd.

Also, after failing to find a record using the value box of the
search, the user has to manually delete the value BEFORE choosing
a new filter field from the combo-box. Is it possible to reset
the value text box when making a new filter field choice?
 
Thank you Allen, i will try it on my form. Do i have to apply the code on my
textbox or on my command button properties/click event? please advise...

thanks
 
Whichever suits.

Personally, I use the AfterUpdate of the text box when the user has only one
option (as in the example in the article), and I use the command button's
click event if there are multiple boxes the user might want to use to find a
record, as in this example:
http://allenbrowne.com/ser-62.html
 
On Mon, 27 Nov 2006 22:58:19 +0800, "Allen Browne"

|To understand why your form opens without anything showing in the Detail
|section, see:
| Why does my form go completely blank?
|at:
| http://allenbrowne.com/casu-20.html
|
|The article suggests possible workarounds.

Thanks for that Allen. Unfortunately it doesn't really solve my
problem.

I think I'll just spend some time working on a standard search
form - which I can use for editing.

Thanks for your help and suggestions.

H.
 
Back
Top