473,735 Members | 6,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5966
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.txtFi lterName) Then
strWhere = strWhere & "([Surname] = """ & Me.txtFilterNam e & """)
AND "
End If

If Not IsNull(Me.txtFi lterTerritory) Then
strWhere = strWhere & "([TerritoryNo] = " & Me.txtFilterTer ritory &
") 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.txtFilterNam e & "*"") 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.m e> wrote in message
news:Zf******** *********@newsf ep4-winn.server.ntl i.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******** *************@n ews-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
1729
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
1354
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 something like JPEG. Thx, Florian
11
1910
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 variable, bar: var bar= "foo";
6
3249
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." exception. The problem is that this exception isn't raised somewhere in a method, so it just shows up, and it causes the application to shut down. Is there anyway how to catch this kinds of exceptions? Can I put somewhere a
4
1398
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
1803
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 FRO A SPECIFIC DATAVALUE AND INSERT IT IN A TEXTBOX IN THE ORIGINAL FORM. I WOULD LIKE TO CREATE A SIMILAR FACILITY IN ASP.NET I DON'T WANT A KEYPRESS FUNCTION I COULD CREATE A BUTTON ON THE SCREEN BUT I WANT TO CREATE A POPUP WINDOW WHERE I COULD...
3
1642
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 (either Windows or Web) I get th following error ------
1
1488
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 for properties that match a certain set of criteria. The problem is this: I need to create a form that allows a user to select for each field of data held about the property a value. For instance someone wants to seach for A house with 2+...
1
2020
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 selected form a drop down bax and Company ID is selected from a combo box. I am trying to create a script that if you click exit form, and one or the other, or both of the fields have a selection it will bring up message box and inform the user of...
0
8962
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
8785
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9463
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
9200
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...
1
6747
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...
0
6049
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4822
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2739
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2188
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.