473,756 Members | 3,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search record form

San
Hey,

I need to create a form with several text boxes in which users type in
key words, press a command button on the form and it opens a matching
record. Thanking you in advance.

Jun 19 '06 #1
6 6926

San wrote:
Hey,

I need to create a form with several text boxes in which users type in
key words, press a command button on the form and it opens a matching
record. Thanking you in advance.


Are you trying to create a filter to a form. You can use the Filter by
Form option in the form itself. It will show all the fields from the
original form which allows the user to enter any key words with
wildcards etc. This is located under Record/Filter/Filter by Form.
The user after entering the keywords in the filter form, right clicks
the form and clicks apply filter. You can add these menu options to
command buttons as well. If you do not want the user to see a record
before using the filter have the form open in a new record first then
use the apply filter by form.

Jun 19 '06 #2
I got the same problem. I need a textbox where I can typ a name, and
when I press enter or a command button it should show me the matching
record in the form (so without opening any other tables or queries or
w/e)
San schreef:

Jun 20 '06 #3

RobK wrote:
I got the same problem. I need a textbox where I can typ a name, and
when I press enter or a command button it should show me the matching
record in the form (so without opening any other tables or queries or
w/e)
San schreef:


If you are trying to just do a search for a form you should:

1. use a combo box instead of a text box that will allow the user to
choose the data not enter the data. this will stop data entry issues.

2. If you are trying to locate a record that is unique you can attach
this to the combo on the after update property after you change it to
match your form:

On Error GoTo xxx
Dim rs As Object
DoCmd.ShowAllRe cords
Set rs = Forms![FormName].Recordset.Clon e
rs.FindFirst "[Title] = '" & Forms![FormName]![ComboName] & "'"
If Not rs.EOF Then Forms![FormName].Bookmark = rs.Bookmark
Forms![Form]![ComboName] = ""
Exit Function
xxx:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

3. If you need to apply a filter so multiple records appear from one
choice:

a. Create the combo that shows the data the user will search by then
attach this statement modified to your form on the after update
property of the combo

On Error GoTo ZZZ
DoCmd.ShowAllRe cords
Dim SrcSQL As String
SrcSQL = "SELECT TableName.* FROM TableName WHERE_
(((TableName.Fi eldName)=[Forms]![FormName]![ComboName]))"
DoCmd.ApplyFilt er SrcSQL
[Forms]![FormName]![ComboName] = ""
Exit Function
ZZZ:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

Note: [Forms]![FormName]![ComboName] = "" is to make the combo become
blank after the search is complete so the user can search again. It
makes a clean search process.

You can also change your error loop message to match an access error
message

MsgBox err.description

4. For both combo search types you need to create a requery for the On
Enter Property to allow the combo to be required each time the user
enters it. This will stop it from droping data that has been added
since the form was opened.

On Error Resume Next
[Forms]![FormName]![ComboName].Requery
Exit Function

Jun 20 '06 #4
San
Hi Cilla,

That sounds pretty easy and logical. I think it is not going to work if
I need to open a matching record from a switchboard?

Cilla wrote:
RobK wrote:
I got the same problem. I need a textbox where I can typ a name, and
when I press enter or a command button it should show me the matching
record in the form (so without opening any other tables or queries or
w/e)
San schreef:


If you are trying to just do a search for a form you should:

1. use a combo box instead of a text box that will allow the user to
choose the data not enter the data. this will stop data entry issues.

2. If you are trying to locate a record that is unique you can attach
this to the combo on the after update property after you change it to
match your form:

On Error GoTo xxx
Dim rs As Object
DoCmd.ShowAllRe cords
Set rs = Forms![FormName].Recordset.Clon e
rs.FindFirst "[Title] = '" & Forms![FormName]![ComboName] & "'"
If Not rs.EOF Then Forms![FormName].Bookmark = rs.Bookmark
Forms![Form]![ComboName] = ""
Exit Function
xxx:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

3. If you need to apply a filter so multiple records appear from one
choice:

a. Create the combo that shows the data the user will search by then
attach this statement modified to your form on the after update
property of the combo

On Error GoTo ZZZ
DoCmd.ShowAllRe cords
Dim SrcSQL As String
SrcSQL = "SELECT TableName.* FROM TableName WHERE_
(((TableName.Fi eldName)=[Forms]![FormName]![ComboName]))"
DoCmd.ApplyFilt er SrcSQL
[Forms]![FormName]![ComboName] = ""
Exit Function
ZZZ:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

Note: [Forms]![FormName]![ComboName] = "" is to make the combo become
blank after the search is complete so the user can search again. It
makes a clean search process.

You can also change your error loop message to match an access error
message

MsgBox err.description

4. For both combo search types you need to create a requery for the On
Enter Property to allow the combo to be required each time the user
enters it. This will stop it from droping data that has been added
since the form was opened.

On Error Resume Next
[Forms]![FormName]![ComboName].Requery
Exit Function


Jun 20 '06 #5

San wrote:
Hi Cilla,

That sounds pretty easy and logical. I think it is not going to work if
I need to open a matching record from a switchboard?

Cilla wrote:
RobK wrote:
I got the same problem. I need a textbox where I can typ a name, and
when I press enter or a command button it should show me the matching
record in the form (so without opening any other tables or queries or
w/e)
San schreef:


If you are trying to just do a search for a form you should:

1. use a combo box instead of a text box that will allow the user to
choose the data not enter the data. this will stop data entry issues.

2. If you are trying to locate a record that is unique you can attach
this to the combo on the after update property after you change it to
match your form:

On Error GoTo xxx
Dim rs As Object
DoCmd.ShowAllRe cords
Set rs = Forms![FormName].Recordset.Clon e
rs.FindFirst "[Title] = '" & Forms![FormName]![ComboName] & "'"
If Not rs.EOF Then Forms![FormName].Bookmark = rs.Bookmark
Forms![Form]![ComboName] = ""
Exit Function
xxx:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

3. If you need to apply a filter so multiple records appear from one
choice:

a. Create the combo that shows the data the user will search by then
attach this statement modified to your form on the after update
property of the combo

On Error GoTo ZZZ
DoCmd.ShowAllRe cords
Dim SrcSQL As String
SrcSQL = "SELECT TableName.* FROM TableName WHERE_
(((TableName.Fi eldName)=[Forms]![FormName]![ComboName]))"
DoCmd.ApplyFilt er SrcSQL
[Forms]![FormName]![ComboName] = ""
Exit Function
ZZZ:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

Note: [Forms]![FormName]![ComboName] = "" is to make the combo become
blank after the search is complete so the user can search again. It
makes a clean search process.

You can also change your error loop message to match an access error
message

MsgBox err.description

4. For both combo search types you need to create a requery for the On
Enter Property to allow the combo to be required each time the user
enters it. This will stop it from droping data that has been added
since the form was opened.

On Error Resume Next
[Forms]![FormName]![ComboName].Requery
Exit Function


Sure it will. Heres a simple example you can use

Dim xxx As String
xxx = [FieldNameFromSw itchboard]
DoCmd.OpenForm "FormToApplySea chTo"
DoCmd.SelectObj ect acForm, "FormToApplySea rchTo"
Dim rs As Object
DoCmd.ShowAllRe cords
Set rs = Forms![FormToApplySear chTo].Recordset.Clon e
rs.FindFirst "[FieldFromFormTo ApplySearchTo] = '" & xxx & "'"
If Not rs.EOF Then Forms![FromToApplySear chTo].Bookmark =
rs.Bookmark
DoCmd.SelectObj ect acForm, "Switchboar d", False
DoCmd.Close
Exit Sub
Note: I am closing my search form (Switchboard) after making my
selection. You don't have to. Just quote out the 'DoCmd.SelectOb ject
acForm, "Switchboar d", False

Jun 20 '06 #6

Cilla wrote:
San wrote:
Hi Cilla,

That sounds pretty easy and logical. I think it is not going to work if
I need to open a matching record from a switchboard?

Cilla wrote:
RobK wrote:
> I got the same problem. I need a textbox where I can typ a name, and
> when I press enter or a command button it should show me the matching
> record in the form (so without opening any other tables or queries or
> w/e)
> San schreef:

If you are trying to just do a search for a form you should:

1. use a combo box instead of a text box that will allow the user to
choose the data not enter the data. this will stop data entry issues.

2. If you are trying to locate a record that is unique you can attach
this to the combo on the after update property after you change it to
match your form:

On Error GoTo xxx
Dim rs As Object
DoCmd.ShowAllRe cords
Set rs = Forms![FormName].Recordset.Clon e
rs.FindFirst "[Title] = '" & Forms![FormName]![ComboName] & "'"
If Not rs.EOF Then Forms![FormName].Bookmark = rs.Bookmark
Forms![Form]![ComboName] = ""
Exit Function
xxx:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

3. If you need to apply a filter so multiple records appear from one
choice:

a. Create the combo that shows the data the user will search by then
attach this statement modified to your form on the after update
property of the combo

On Error GoTo ZZZ
DoCmd.ShowAllRe cords
Dim SrcSQL As String
SrcSQL = "SELECT TableName.* FROM TableName WHERE_
(((TableName.Fi eldName)=[Forms]![FormName]![ComboName]))"
DoCmd.ApplyFilt er SrcSQL
[Forms]![FormName]![ComboName] = ""
Exit Function
ZZZ:
MsgBox "There was an error executing the command.", vbCritical
Exit Function

Note: [Forms]![FormName]![ComboName] = "" is to make the combo become
blank after the search is complete so the user can search again. It
makes a clean search process.

You can also change your error loop message to match an access error
message

MsgBox err.description

4. For both combo search types you need to create a requery for the On
Enter Property to allow the combo to be required each time the user
enters it. This will stop it from droping data that has been added
since the form was opened.

On Error Resume Next
[Forms]![FormName]![ComboName].Requery
Exit Function


Sure it will. Heres a simple example you can use

Dim xxx As String
xxx = [FieldNameFromSw itchboard]
DoCmd.OpenForm "FormToApplySea chTo"
DoCmd.SelectObj ect acForm, "FormToApplySea rchTo"
Dim rs As Object
DoCmd.ShowAllRe cords
Set rs = Forms![FormToApplySear chTo].Recordset.Clon e
rs.FindFirst "[FieldFromFormTo ApplySearchTo] = '" & xxx & "'"
If Not rs.EOF Then Forms![FromToApplySear chTo].Bookmark =
rs.Bookmark
DoCmd.SelectObj ect acForm, "Switchboar d", False
DoCmd.Close
Exit Sub
Note: I am closing my search form (Switchboard) after making my
selection. You don't have to. Just quote out the 'DoCmd.SelectOb ject
acForm, "Switchboar d", False


and quote out the DoCmd.Close Too

Jun 20 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3534
by: CharitiesOnline | last post by:
Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned from my search and how many records I have set it to display per page. All great so far, HOWEVER..... When you click the next link to see the next 10 results on the next page, it just dumps the search details and pulls up all the records in the...
2
2404
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is to search by one ingredient, sometimes by two, and sometimes by three. There won't always be a second and third ingredient to search on. It will depend on how the user wants to search. The database set up with multiple tables mainly one for all the details related to the recipe and...
1
1814
by: Jack-of-all-traits | last post by:
This is a big problem and I really need help, no one seems to know how to solve this problem. I want to take the data from a record in a particular a field that contains the names of generic products made up of 1 to 4 words and search each record online, on a search engine such as the google.com or altavista.com. Then also retain or record the results given for the number of hits form the search engine website... take the number of...
9
20317
by: Christopher Koh | last post by:
I will make a form which will search the database (just like google interface) that will look/match for the exact name in the records of a given fieldname. Any suggestions on how to make the code?
8
3221
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled 'search' may be clicked on by the user and the user can then search all records by postcode. I want to do this to prevent duplicate data entry.
3
4985
by: Stu | last post by:
Hi, I've been looking through the archives but can't find what I'm looking for, or due to my limited experience with Access97, didn't recognize it... I've created a database that is going to be used for updating procedures at several different sites, and am stumped at creating a search feature. There is one main form with six subforms linked to it, and I'm not sure the best way to set up the search parameters. I'm still learning VB and...
3
1596
by: kaosyeti | last post by:
i need to do a record search in a form but there are a few twists. 1. there is no unique field to any of these records 2. the form has 9 fields, 5 of which are required for creating a record. 3. the solution has to be super easy for the end-users of this database. i'm thinking of a command button that pops up a form that let's a person select up to 3 criteria (2 of which are one of the required fields mentioned earlier and 1 is not --...
9
2813
by: AMBLY | last post by:
Hello ! Hope someone might be able to help me with this one. I run Access2000 on XP. I have a form : frmONE- which contains a txt field: ctrCTN from my table/database. The values in ctrCTN are unique. Next to this field is a cmdFIND button frmONE is open and the active window. I want to search for values in ctrCTN, and go to the record which contains that value. I do not want to use a cmdButton with in-built Access Find procedure to...
5
1966
by: Deano | last post by:
Perhaps this has been asked before but there might be some up to date thinking about this. I really need a better search function for my asset register. I allow assets to be entered and tracked over a period of time. There can be quite similar assets and simply choosing from the combo box is not enough. I need something more sophisticated. How hard is it to get a listing that grows as I type in a search term, character by...
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.