473,738 Members | 6,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem - Searching Records In The Form

6 New Member
Using MS ACCESS 2002

I developed a FORM, and within that FORM, I created and added a SEARCH BUTTON, and then I created a SUB-FORM, so that when an the END USER clicks on the FORM it will POP-UP the SUB-FORM, and in that SUB-FORM I added all the FIELDS of the information I wanted to view. The SUB-FORM was created to do the actual SEARCHING.

However, when I want to search a RECORD and I type in DATA of a specific RECORD into the FIELDS in the FORM I created, it does not let me! I would like to have MS ACCESS pull the RECORD when I type it into the FIELD(s). The way I am retrieving the information when I am searching a RECORD is by scrolling through all the RECORDS in the DATABASE, or if I click on the "FIND" button option in the standard MS ACCESS toolbar.

I want to use the FIELD option that I created in the FORM and type in the information so that MS ACCESS can pull that specific record, can someone help me with this? How am I able to:
1.) Enter Data into the Fields I created
2.) Have MS ACCESS pull the Record by typing information on the FIELDS I created in the FORM.

Thanks so much in advance for your help!
Jan 5 '07 #1
11 3440
nico5038
3,080 Recognized Expert Specialist
There are many ways to search in Access.
Personally I never create searchforms, but instruct my users to use the right-click pop-up menu. This will give a very versatile search facility (inclucing partial matches) and my users really feel in control.

Idea ?

Nic;o)
Jan 6 '07 #2
pks00
280 Recognized Expert Contributor
What is your main form used for, anything?
What u could do is this

On a form, use the form header, add your search textboxes in there, then a btn

The form is based on a table or query that u want to search on

What u can then on the click event is to use the form's filter event

simple example
form is based on a table called tblMeow, it has the following fields ID, Cat, Name
u have a two textboxes txtCat and txtName in the form header, and a btn called cmdFind

Expand|Select|Wrap|Line Numbers
  1. private sub cmdFind_Click()
  2.  
  3.     Dim sWhere as String
  4.  
  5.     sWhere = ""
  6.     if isnull(Me.txtCat) = False then sWhere = "Cat = '" & Me.txtCat & "'"
  7.     if isnull(Me.txtName) = False then
  8.         if sWhere <> "" then sWhere = sWhere & " AND "
  9.         sWhere = sWhere "Name = '" & Me.txtName & "'"
  10.     end if
  11.  
  12. 'Note if u filter on numeric values then u do not wrap with single quotes
  13.  
  14.     If sWhere <> "" then
  15.         Me.Filter = sWhere
  16.         Me.FilterOn = True
  17.     else
  18.          Me.FilterOn = False
  19.     End if
  20. end sub
Jan 7 '07 #3
TheDataGuy
6 New Member
Hello People, and thanks for your previous help! Now, I would like to be able to search in more than one field on the form that I created. The current problem is I am only able to pull out records by using only ONE search field. For example, let me explain what I would like:

I would like Access to pull records by either typing into the fields FirstName, or LastName, OR Location, OR, STATUS, can I do that in ACCESS? I have about 8 FIELDS in my FORM and I would like to use any FIELD to pull out RECORDS, is that possible? THANKS SO MUCH!
Jan 11 '07 #4
nico5038
3,080 Recognized Expert Specialist
Use the OR tab of the QBF form. It's located bottomleft.

Nic;o)
Jan 12 '07 #5
TheDataGuy
6 New Member
Can you please be more specific? I am very new to creating databases, as a matter of fact this is my first real MS ACCESS database that I am creating. So some of the terminology might be clueless to me.

So again, I have a search function that I created on the FORM but it only searches one criteria. I have many fields that I would like to search records by, I have never created a MACRO, or any sort of Script, so is it possible you show me in detailed?

Thanks so much in advance!
Jan 12 '07 #6
nico5038
3,080 Recognized Expert Specialist
At the top of the form you'll find a button "Query by Form".
When you press that you can enter criteria for filtering the records.
This includes a search with wild characters like:
*x*
to find all strings with an "x" or:
>1000
to find all numbers larger as 100.

A bit clearer ?

Nic;o)
Jan 12 '07 #7
TheDataGuy
6 New Member
HELP PLEASE - THIS IS WHAT I AM GETTING:

Option Compare Database

Private Sub Command26_Click ()
On Error GoTo Err_Command26_C lick


Screen.Previous Control.SetFocu s
DoCmd.DoMenuIte m acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Command26_ Click:
Exit Sub

Err_Command26_C lick:
MsgBox Err.Description
Resume Exit_Command26_ Click

End Sub

Private Sub Command26_Enter ()

End Sub

BUT THIS IS WHAT I WOULD LIKE:
private sub cmdFind_Click()

Dim sWhere as String

sWhere = ""
if isnull(Me.txtCa t) = False then sWhere = "Cat = '" & Me.txtCat & "'"
if isnull(Me.txtNa me) = False then
if sWhere <> "" then sWhere = sWhere & " AND "
sWhere = sWhere "Name = '" & Me.txtName & "'"
end if

'Note if u filter on numeric values then u do not wrap with single quotes

If sWhere <> "" then
Me.Filter = sWhere
Me.FilterOn = True
else
Me.FilterOn = False
End if
end sub

The fields on the form are as follows:

OM# Business
File Name Dept
State Note
Purpose Initials
Reviced Date
File Type

Can anybody help me with this? I need to be able to search records using any of the above fields.

Thanks so much!
Jan 12 '07 #8
MSeda
159 Recognized Expert New Member
I, Don't mean to complicate the discussion by throwing another idea into the mix but I can't help my self.
I like to set up search forms with a combobox that allows a user to select a the field to search and whether to search anywhere, starts with or exact matches (not unlike access).
the form is pretty simple a textbox to enter the search term, a combobox to choose the fields to search, a combobox to choose how to search, a subform(continu ous) to display results and a command button that executes the following code.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command37_Click() 'New Search
  2. Dim FieldRS As ADODB.Recordset
  3. Dim MatchTerm As String
  4. Dim fieldsql As String
  5.  
  6. 'make previous results invisible
  7. Me.Label74.Visible = False
  8. Me.ResultCC.Visible = False
  9.  
  10. 'put correct syntax around the search term
  11. Select Case Me.SMatch
  12. Case "Anywhere"
  13.     MatchTerm = " Like '*" & Me.STerm & "*'"
  14. Case "Exact Match"
  15.     MatchTerm = " Like '" & Me.STerm & "'"
  16. Case "Begins With"
  17.     MatchTerm = " Like '" & Me.STerm & "*'"
  18. End Select
  19.  
  20. 'make recordset of names of fields to search
  21. If Me.SField = "Search All Fields" Then
  22. Set FieldRS = New ADODB.Recordset
  23. FieldRS.Open "SELECT [Data Search Fields].* FROM [Data Search Fields] Where [Table Name] = 'Client Table';", CurrentProject.Connection
  24. Else
  25. Set FieldRS = New ADODB.Recordset
  26. 'I actually have a table that lists all of my fields and then assigns a 'Search Name' , a plain english name if you will, it also groups similar fields like phone numbers since there are several fields in my client table where phone numbers are stored the user need only select 'Phone' once to search all of them
  27. FieldRS.Open "SELECT [Data Search Fields].* FROM [Data Search Fields] Where [Search Name] = '" & Me.SField & "' AND [Table Name] = 'Client Table';", CurrentProject.Connection
  28. End If
  29.  
  30. 'build sql string searching selected fields
  31. Do Until FieldRS.EOF
  32.     fieldsql = fieldsql & "[" & FieldRS![Field Name] & "]" & MatchTerm
  33.     FieldRS.MoveNext
  34.     If Not FieldRS.EOF Then
  35.     fieldsql = fieldsql & " OR "
  36.     End If
  37. Loop
  38.  
  39. 'create a temporary table of search results and set subforms recordsource
  40. Me.ResultCC.Form.RecordSource = ""
  41. DoCmd.RunSQL "SELECT [Client Table].* INTO [TempRecordSet] FROM [Client Table] WHERE " & fieldsql & ";"
  42. Me.ResultCC.Form.RecordSource = "SELECT TempRecordSet.* From TempRecordSet"
  43.  
  44. 'make 'No Results' label visible
  45. If IsNull(ELookup("[Client Code]", "[TempRecordSet]")) Then
  46. Me.Label74.Visible = True
  47. Else
  48. Me.ResultCC.Visible = True
  49. End If
  50.  
  51. End Sub
if you'd like any further explinations just post back.
Jan 13 '07 #9
nico5038
3,080 Recognized Expert Specialist
If you want to rebuild the right-click and/or QBF, be my guest :-)

To partially overcome the trouble with filled or empty comboboxes use for the combo:

select "*" as ID, "<all>" as description from Yourtabel
UNION
select ID, description from Yourtabel

Now use:

if len(nz(me.combo box)) > 0 then
strWhere = strWhere & " and ID like '*" & me.combo & "*'"
endif

Thus you get a match or all rows.

Nic;o)
Jan 13 '07 #10

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

Similar topics

3
2803
by: Simone | last post by:
Hi All, I have a Find Record button setup in most of my forms in order to find a specific customer's details. I have just noticed today though that this search will only find the customer if it already has linked data in the subform. This totally defeats the purpose of my search, which is to find an existing customer's details in order to enter new data in the subform. I was wondering if there is a way, in the form/subform situation,...
0
1127
by: Howie | last post by:
Hi all. Hope you can help. I have created a form to edit existing records. I want to do two things: 1/ When the form opens, I want it to give a search field (searching on a string) which then returns a list of matching records which I can choose from. 2/ After editing, I want to use the 'before update' option to pop
7
2415
by: evilcowstare via AccessMonster.com | last post by:
Hi, I have searched the forum for answers on this and to be honest as a novice I find it a bit confusing so apologies if it is simple. There are some searches that I want to apply to my database. 1. To search for all records between 2 dates and display them in a report 2. To be able to show all records which have a selection against them made from a combo box 3. To be able to combine the two, selecting the option from a combo and then...
7
4538
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent records. Should I design a new form for this or can I somehow make this work in the same form. Thanks in advance, john
1
1266
by: arnold | last post by:
Hi all, I have created a form which gives the user the ability to search for specific data. Number of records in my database exceed one million records therefore in some occasion the searching takes an approximately a long time. Hence I have decided to show a hint message to inform the user that searching is going on and he has to wait. So in this regard I have created a label which is invisible at the beginning when the user...
5
1988
by: sandipon | last post by:
I have used the following Pagination script to display database records in a series of pages, but only the first page shows up properly, and on clicking the links of subsequent pages or the NEXT , LAST page links, No records are displayed but only the Message - "Sorry, No records Found!!".shows up. I guess some form fields values which contain multiple strings with spaces between them are not properly collected into the variables in the ASP...
2
1110
by: preeti13 | last post by:
hi friends please help me with my problem i have a code for search application it is searching one record from the data base at a time but i have so many records with that name but its not searching the whole list please help me how i can search the whole list of the same names my code is like this <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="SearchReport.Report" %> <!DOCTYPE html PUBLIC "-//W3C//DTD...
0
1648
by: cannonpm | last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a search form modeled after Allen Browne's search form (http:// allenbrowne.com/ser-62.html). It works well except for records which have multiple related records in 1:many relationships and many:to:many relationships. To view my results, I created a query called qryAllData which contains all of the data from several tables for each record. For example, say I have one...
2
3013
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my local system that validations work.plz tell that whats the problem in that. Here is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html...
0
8968
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
8787
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
9473
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
9208
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
6750
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
6053
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
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
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
3
2193
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.