472,330 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 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 5829
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...
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...
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. ...
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...
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...
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...
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...
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...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.