473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

A97 - Creating a Seach form

Now this shouldn't be hard but I've been struggling on the best way as to
how to do this one for a day or 3 so I thought I'd ask the assembled
company.....

I'm writing an application that tracks a group of Sales people, the
customers they deal with and the business they transact with them.

I've got my head around all the tables & some of the basic Query structures
OK and am beginning to delve into creating the forms I need to be able to
add, edit & view information.

One of the things I need to be able to do is to find & display a record on
an individual Salesman, Customer or a single order quickly. I'm trying to
create a fairly "sealed" environment for the user so all standard toolbars &
menus will be locked off . The basic forms I have created for viewing data
are non-editable & you can't add new records from them - you need to go
elsewhere to do that. To edit you need to press an "Edit button" & this will
then isolate the single record to be edited. There will be a clear
indication when the thing is in "Edit Mode" and when its not. Some data can
not be edited by users at all. Basically I'm trying to make it fairly idiot
proof!

What I want is to create the ability for the user to search for data from
the "View" form. There are, realistically, about 4 or 5 different fields
they could search on to find a particular Salesman or Customer's record for
example. So I've thought about putting the form into filter mode or I could
use a simple dialogue to "Find" a record. Ideally what I'd like to do is to
pop a small form up that has text boxes on it to capture search criteria for
any or all of the 4 or 5 different things that a user might search on....for
example he might find a Salesman based on his name, his territory number or
his Unique reference number (which is something I have created).

So I have a small form with something like

Name: ..............
Territory No..........
URN............

The user types some text into one or more of the boxes & then hits a button
(or possibly using an "After Update Event) the thing locates the Salesman's
data, the search form closes and the relevant record is displayed on the
main "View" Form behind.

It could execute some kind of query that might produce a small set of
records that the user could scroll through or another option might be to
pull up a continuous form/list with basic details of Salesmen who part-match
the criteria entered from which the user can select one to be displayed by
clicking on a row in the list.

The user might have to hit another button on the view form to return it to
"View all Records Mode".

Any help as to how to make this work or indeed alternative & more efficient
suggestions gratefully received. On scaling, there might be several tens of
sales people, Hundreds of customers and possibly thousands of orders over
time.

All help gratefully received!

rgds

Iain
Nov 12 '05 #1
2 5939
Iain, your question is something of an onion: could be lots of layers here.
:-)

A simple interface is a form in Continuous view to display the search
results. Place the search boxes and buttons into the Form Header section.
The Search button either applies a filter to the form, or changes its
RecordSource if you need more power than a filter can give.

The basic idea looks like this:
-----------code starts--------------
Private Sub cmdSearch_Click()
Dim strWhere As String
Dim lngLen As Long

If Not IsNull(Me.txtFilterName) Then
strWhere = strWhere & "([Surname] = """ & Me.txtFilterName & """)
AND "
End If

If Not IsNull(Me.txtFilterTerritory) Then
strWhere = strWhere & "([TerritoryNo] = " & Me.txtFilterTerritory &
") AND "
End If

'etc for other boxes.

'Apply the filter
lngLen = Len(strWhere) - 5 'Without trailing " AND "
If lngLen <= 0 Then
MsgBox "No criteria."
Else
Me.Filter = Left(strWhere, lngLen)
Me.FilterOn = True
End If
End Sub
-----------code ends--------------

You can add as many boxes to that as you need.

Notes:
1. Use the correct delimiter for each field types: quotes for Text, # for
dates, nothing for numbers.

2. If you have a field named "Name", watch out: Forms and other objects have
a Name property, and Access may get confused about what you are talking
about.

3. Use the Like operator for text fields if desired.
... & "([Surname] Like """ & Me.txtFilterName & "*"") AND "

4. Build a complete SQL statement (like a query in SQL View), and assign to
the form's RecordSource if necessary.

5. Use subqueries as well if you need to filter on data that is in related
tables.

6. There are a couple of bugs in Access that can mess up the display of
controls in the Form Header section when the filter returns no records and
no new records can be added.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"Iain Miller" <do***@spam.me> wrote in message
news:Zf*****************@newsfep4-winn.server.ntli.net...
Now this shouldn't be hard but I've been struggling on the best way as to
how to do this one for a day or 3 so I thought I'd ask the assembled
company.....

I'm writing an application that tracks a group of Sales people, the
customers they deal with and the business they transact with them.

I've got my head around all the tables & some of the basic Query structures OK and am beginning to delve into creating the forms I need to be able to
add, edit & view information.

One of the things I need to be able to do is to find & display a record on
an individual Salesman, Customer or a single order quickly. I'm trying to
create a fairly "sealed" environment for the user so all standard toolbars & menus will be locked off . The basic forms I have created for viewing data
are non-editable & you can't add new records from them - you need to go
elsewhere to do that. To edit you need to press an "Edit button" & this will then isolate the single record to be edited. There will be a clear
indication when the thing is in "Edit Mode" and when its not. Some data can not be edited by users at all. Basically I'm trying to make it fairly idiot proof!

What I want is to create the ability for the user to search for data from
the "View" form. There are, realistically, about 4 or 5 different fields
they could search on to find a particular Salesman or Customer's record for example. So I've thought about putting the form into filter mode or I could use a simple dialogue to "Find" a record. Ideally what I'd like to do is to pop a small form up that has text boxes on it to capture search criteria for any or all of the 4 or 5 different things that a user might search on....for example he might find a Salesman based on his name, his territory number or his Unique reference number (which is something I have created).

So I have a small form with something like

Name: ..............
Territory No..........
URN............

The user types some text into one or more of the boxes & then hits a button (or possibly using an "After Update Event) the thing locates the Salesman's data, the search form closes and the relevant record is displayed on the
main "View" Form behind.

It could execute some kind of query that might produce a small set of
records that the user could scroll through or another option might be to
pull up a continuous form/list with basic details of Salesmen who part-match the criteria entered from which the user can select one to be displayed by
clicking on a row in the list.

The user might have to hit another button on the view form to return it to
"View all Records Mode".

Any help as to how to make this work or indeed alternative & more efficient suggestions gratefully received. On scaling, there might be several tens of sales people, Hundreds of customers and possibly thousands of orders over
time.

All help gratefully received!

rgds

Iain

Nov 12 '05 #2

"Allen Browne" <ab***************@bigpond.net.au> wrote in message
news:uR*********************@news-server.bigpond.net.au...
Iain, your question is something of an onion: could be lots of layers here. :-)


Allen,

thanks for your help in skinning my onion!

I.
Nov 12 '05 #3

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

Similar topics

5
by: Zeeshan | last post by:
In What are the possible ways to get hogh ranking in seach engine ? I know sone way as follows: 1. Executing .html extension as php file through .htaccess file 2. XML object of javascript etc
1
by: Florian Lindner | last post by:
Hello, I'm looking for libraries to create graphs. I'm not talking about plotting a function like f(x)=x^2 just plotting a couple of values into a short, maybe interpolating them. Output should be...
11
by: Lord Khaos | last post by:
If I am trying to find an expression, foo, I can do something like this: rExp = /foo/gi; if(results.search(rExp) > -1){ and all work fine. however, if I want my search term to be a...
6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
4
by: Filips Benoit | last post by:
Dear All, I want to seach the code of all forms for a string. My code below only works for open forms. I want it to work for all forms. See *** Problem line **** Thanks,
2
by: GMK | last post by:
HI ALL I'M COMING FROM A FOX PRO BACKGROUND WHERE I COULD IN A VERY EASY WAY CREATE A SEACH FACILITY BY PRESSING N F1 AND ANOTHER WINDOW WILL DIRECTLY APPEAR WHICH WOULD LET THE USER TO SEARCH...
3
by: Ricco DeCicco | last post by:
Hi All I have just reinstalled VStudio.Net (VB.Net) and the .Net Framewor and I can successfully open an existing project for editin 'UserControlSample' When I try to create a new project...
1
by: joepollard | last post by:
For a project I have been asked to create a database system for use in an Estate Agents. Obviously the main function of such a system would be the need for a user to seach through the database...
1
by: OxfordConsult | last post by:
I have a form and it is to creat a 'link' between a project and a company. Creating a record form this table will simply create a record in a databse with the company ID and project ID. Project ID is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...

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.