Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO CREATE A SEARCH TOOL IN THE DATABASE? 1

Status
Not open for further replies.

Giovanni

Technical User
Mar 14, 2000
9
US
i have a MS Acess database (tables with data)<br>

i have a not working form that i wuold like to MAKE :) work and search for entries (records) within the database.<br>

<br>

search should be based on :<br>

document type (agenda, minutes, etc.)<br>

date of publication<br>

document unique number<br>

<br>

How can I do it?<br>

I'd be very grateful for any help!<br>

<br>

THANK YOU!!!
 
Well one way is to make a query.<br>
Thats its purpose, to ask questions of your data.<br>
to Create a new query Click the Queries TAB<br>
then add your table<br>
Next drag just the columns you are interested in down to the bottom.<br>
Click the (Red Exclamation mark)<br>
You will see all of the records in your table.<br>
Look in the &quot;date of publication&quot; column and find a example date. Say 1/3/00<br>
Click the design button(Cyan colored Triangle) which will bring you back to design mode.<br>
Next put a criteria in &quot;date of publication&quot; column 1/3/00<br>
Run your query again.<br>
I wil return less records matching those that are for that date.<br>
Now you can match other column too<br>
Just put a criterai in each one and when you run the query it will bring back less and less records.<br>
<br>
OK Thats just a start.<br>
Good luck.<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Well, <br>
I kinda know how to do the query search. It's easy, just adding a criteria.<br>
<br>
I have lots of records in the table though. The thing I wanted to do, but can't solve the problem yet, is that I would like to create the FORM that searches for specific record and gives me the output in a report form.<br>
<br>
Let's say <br>
I want &lt;type of document&gt; - contract<br>
&lt;date of publication&gt; - between 12/12/1998 and 06/01/1999<br>
<br>
So I want the database to display all matching records.<br>
<br>
PLEEEAASEE :eek:) Ho can I do that?
 
Giovanni,<br>
You need to decide how complex you want the search...I've done forms that can allow the user to search on any field in any table in the db, but this takes time to build. To start with, you should just experiment with building simple SQL statments over one table on the fly, and expand from there. FOr instance, on a button on your form you could have it search for Customers, and have textboxes txtCustCith and txtCustName<br>
<br>
dim sq as string,qd as querydef<br>
sq = &quot;Select * From Customers WHERE &quot;<br>
sq = sq & &quot; CustCity = &quot;&quot;&quot; & me!txtCustCity & &quot;&quot;&quot;&quot;<br>
If not isnull(me!txtCustName) then<br>
&nbsp;&nbsp;&nbsp;&nbsp; sq = sq & &quot; AND custname like &quot;&quot;*&quot; & me!custname & &quot;*&quot;&quot;&quot;<br>
end if<br>
set qd = currentdb.querydefs(&quot;tempquery&quot;)<br>
qd.sql = sq<br>
docmd.openquery qd.name<br>
<br>
Then the sky's the limit--you can add acombo box to select the table name, basing the box on MsysObjects, other listboxes can be field with the field names from the selected tables, you can create controls on the fly after the user selects a table and fields, so you can have new fields that match the name and type of the fields chosen, etc. I've gotten crazy with these...but if this is for end users always remember--they always ask for and demand more than they need or will use, so it's best to keep things simple! :)<br>
--Jim
 
THANKS :eek:)<br>
<br>
I'm afraid I'm too unexperienced in MS Access -- SQL statements is something over my head now. Gees, it's killing me. Where do I start? :eek:)<br>
<br>
<br>
Let me try, and I know I'll be back in few minutes :)<br>
<br>
THANK YOU VEEEERRRRRRRRYYYYYYYY MUCH!
 
Here is the query SQL statement<br>
<br>
SELECT [Main Table].*, Availability.*, [Point of Contact].*, [Bounding Coordinates].*<br>
FROM [Bounding Coordinates] INNER JOIN ([Point of Contact] INNER JOIN (Availability INNER JOIN [Main Table] ON Availability.ID = [Main Table].Availability) ON [Point of Contact].ID = [Main Table].[Point of Contact]) ON [Bounding Coordinates].ID = [Main Table].[Spatial Reference];<br>
<br>
HELP :)<br>
<br>
(Jim, will i ever get smart in this stuff?)
 
Well you are half way there.<br>
If you want to use the query Gird to get your feet wet. Then put the code you posted right in the &quot;date of publication&quot; column criteria box.<br>
Copy and paste this right out of here to your query.<br>
the whole line &quot;Between and all&quot;<br>
<br>
between 12/12/1998 and 06/01/1999<br>
<br>
Run it (click the Red Exclamtion mark)<br>
It will return just those records.<br>
Now as you get used to it, Create your query in the Grid then Click the SQL button and have a look at what Access is really doing.<br>
Which is the code like JimHorton displayed.<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Oops, that's was the wrong part of code<br>
<br>
Thanks Doug!<br>
<br>
I'll try<br>
<br>
it's so overwhelming<br>
<br>
<br>
SELECT [Main Table].[Document Type], [Main Table].Title, [Main Table].[Originator: Department/ Agency Name], [Main Table].Abstract, [Main Table].Purpose, [Main Table].Availability, [Main Table].[Point of Contact], [Main Table].[Spatial Reference], [Main Table].[Control Identifier], [Main Table].[Date of Publication], [Main Table].[Date of Last Modification], [Main Table].[link to file], [Main Table].[name of the file], *<br>
FROM [Bounding Coordinates] INNER JOIN ([Point of Contact] INNER JOIN (Availability INNER JOIN [Main Table] ON Availability.ID = [Main Table].Availability) ON ([Point of Contact].ID = Availability.ID) AND ([Point of Contact].ID = [Main Table].[Point of Contact])) ON ([Bounding Coordinates].ID = Availability.ID) AND ([Bounding Coordinates].ID = [Main Table].[Spatial Reference])<br>
WITH OWNERACCESS OPTION;
 
Yep, it works... But I'm so much far from the result that is needed... <br>
I hate to be somebody's pain in a neck.<br>
<br>
statement "between and " worked fine<br>
<br>
but how do i make the db search for particular thing<br>
<br>
i just have no clue where and how to enter that part of the code Jim gave me<br>
<br>
oh', i'm so dumb
 
I think you're confused by Jim's SQL code<br>
and when and where to use it.<br>
you don't have to use it at all.<br>
Thats what the Grid is for to make it simple to find your data.<br>
Let Access take care of the SQL behing the scene's<br>
Like your SQL you pasted<br>
I'm sure you did not know the first thing about it.<br>
And that's OK<br>
So just use the Grid and put in what you want and run it and forget the SQL for now.<br>
You can use Access and not even worry about the SQL code.<br>
It there but you don't have to know or understand it to use Access.<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Did you have a chance to take a look the form in the database? This is how the end product should work. You might get the idea from looking at the FORM1 in the database. <br>
The user should have the acceess to GUI only and all the tables won't be seen as they are now. <br>
<br>
you enter the data and click search, the database should give you the result with a link to the file.<br>

 
Giovanni,<br>
It sounds like you're on your way...A couple things to keep in mind (it may be too late now, but if you can change the db to this suggestion, it's helpful): <br>
<br>
Never use spaces in table names or field names. Access allows this, but I have seen (and I'm not kidding) complete sentences as table and field names, including some punctuation! This makes these sql statements look much more confusing than they are, additionally Access puts in [] brakets by default, and they're needed when you have spaces. When you write sql in code you can avoid these brackets if you avoid spaces (use under_scores to separate words if needed) Keep table/field names within a good balance of descriptiveness and length, but in any case, don't use spaces.<br>
<br>
--Jim
 
Thank you for your help Jim.<br>
Look forward to hearing from you. <br>
<br>
jtairov@hotmail.com<br>
<br>

 
A different way to try would be to put the following in your query in the order that you want your data displayed: In the query criteria type [Please enter the data you are looking for] This will cause a dialog box to appear asking for the data. When the user types the data in the box it will return only what matches exactly what is typed. You can also put: Like[Please enter the data you are looking for] and have the user type an * before and/or after a partial spelling of the data. This returns all data that is like what has been typed. Ex: Aug* would return August, Augusta and Augment and *ness would return enything ending in ness. Keying just the * would return all data in that field. You can do this in more than one field and it will act like the filter by selection option drilling down until you have only the data you are looking for. This was an easy way for me to get data when I was learning to use Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top