473,406 Members | 2,867 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,406 software developers and data experts.

Finding records using a VB button

Hi,
I'm an access 2003 novice trying to improve the search ability of my club membership database. I am currently searching for the members surnames by simply running a query (Please enter surname in the critieria field or the query) which then returns the records of everyone matching the surname entered. This is pretty rubbish as there is no error handling functionality and requires the user to scroll through the records if more than one person with the same surname exists.

Therefore, is there a simple way to improve the search function by using VB or SQL code which would allow error handling, should there be no record found?

Cheers for your help.
Mar 14 '07 #1
2 1518
missinglinq
3,532 Expert 2GB
I would first use DCount to see if you're going to get a match, and then if a match exits, run your query.

Where RunSearch is the command button, Surname is the name of the field in the table ClubTable, and SearchName is the control on the form where the search string is entered. You'll need to substitute your own actual names for these, of course.
Expand|Select|Wrap|Line Numbers
  1. Private Sub RunSearch_Click()
  2. If DCount("[Surname]", "ClubTable", "[Surname]= '" & Me![SearchName] & "'") < 1 Then
  3.   Response = MsgBox("There are no records that match!", vbOKOnly, "Match Not Found!")
  4.    Me.SearchName = ""
  5. Else
  6.    'Place your query here
  7.    Me.SearchName = ""
  8. End If
  9. End Sub
  10.  
This is pretty rubbish as...the user (has) to scroll through the records if more than one person with the same surname exists.
A query seems the appropriate method to use when the possibilty of the search returning more than one record exists. I'm really not sure how you expect to move thru multiple records except to scroll thru them.
Mar 17 '07 #2
NeoPa
32,556 Expert Mod 16PB
This may, or may not, help (Example Filtering on a Form.).
You will still need to consider the situation where none is found, but you can, with intelligent use of filtering, reduce the number of matches severely by more filtering. See what you think anyway.
Mar 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: CSDunn | last post by:
Hello, I have an Access 2000 Project in which the data comes from a SQL Server 2000 database, and multiple users need to be able to see new records as each user adds records. The users also need...
2
by: Antitax | last post by:
I have a database with more than 800 adress records Some of the are similar because some letters in the street adress for example are not identical, altough they point to the same adress. Does...
2
by: David | last post by:
Hi, I have an order form which has a field 'ProductID'. This form has a button on each record to open a new form linked by ProductID. This new form is a continuous form and obviously, only...
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
4
by: LetMeDoIt | last post by:
Greetings, I'm using ASP to retrieve from MSSQL and I then populate a table. After several months of successfull retrieves, this same code now bombs out. It turns out that if I clear out from...
1
by: Mcoleman | last post by:
Hi all My problem is this, I am trying to get my report which works fine, to open at a user specified place in the total amount of records. So in other words, when the user clicks the button to...
3
by: Redbeard | last post by:
Hi All this is my first time post, be gentle. I am looking at creating a keyword search that searches multiple fields in a Form and then filters records that match the keyword. The Form...
7
by: squrel | last post by:
Hello everybody.. I have a form to find the records according to contact name and pono... in tht i have a find button tht by clicking has to point to my main grid (frmpo) and show the pono which...
1
by: Deepmala26 | last post by:
Hi, I m doing a project in VB.NET. I've created form and database connectivity is done. I've displayed data in Datagrid through which user can sort and find records. for finding...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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...

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.