473,386 Members | 1,754 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,386 software developers and data experts.

Search query in access

Hi

An Access database I am creating which is designed for a rental shop, I have the following table :

Field 1 : Account ID
Field 2: FILM ID 1
Field 3: FILM ID 2
Field 4: FILM ID 3
Field 5: FILM ID 4
Field 6: FILM ID 5

The account id of course refers to the customers account, and FILM ID 1-5 is the customers top five most rented films. This would help the staff determine possible trends in film choices with a particular customer.

When I attempt to create a query in the QBE pane, I would like to know if it is possible for the user to type in a FILM ID once but fields 2-6 are all checked in order to find the correct result. Currently If i want to search fields 12-6 I need to search each field individually and type in the FILM ID five times.

Yours gratefully
Feb 24 '07 #1
12 2242
ADezii
8,834 Expert 8TB
Hi

An Access database I am creating which is designed for a rental shop, I have the following table :

Field 1 : Account ID
Field 2: FILM ID 1
Field 3: FILM ID 2
Field 4: FILM ID 3
Field 5: FILM ID 4
Field 6: FILM ID 5

The account id of course refers to the customers account, and FILM ID 1-5 is the customers top five most rented films. This would help the staff determine possible trends in film choices with a particular customer.

When I attempt to create a query in the QBE pane, I would like to know if it is possible for the user to type in a FILM ID once but fields 2-6 are all checked in order to find the correct result. Currently If i want to search fields 12-6 I need to search each field individually and type in the FILM ID five times.

Yours gratefully
Your current Table structure is definately not conducive to extracting data such as you are describing. Ideally, you should have a Customers Table (tblCustomers) and a Rental Table (tblRentals) linked in a 1 to MANY Relationship via an AccountID. All Rentals would now reside in Child Table and requested statistics on Rented Films would be a breeze.
Feb 24 '07 #2
Hi

Thank you for your post. I could rearrange the table structure, however I really would like to know if it would be possible to search multiple fields using one entry however ? is this possible ?

thank you
Feb 24 '07 #3
NeoPa
32,556 Expert Mod 16PB
Hi

An Access database I am creating which is designed for a rental shop, I have the following table :

Field 1 : Account ID
Field 2: FILM ID 1
Field 3: FILM ID 2
Field 4: FILM ID 3
Field 5: FILM ID 4
Field 6: FILM ID 5

The account id of course refers to the customers account, and FILM ID 1-5 is the customers top five most rented films. This would help the staff determine possible trends in film choices with a particular customer.

When I attempt to create a query in the QBE pane, I would like to know if it is possible for the user to type in a FILM ID once but fields 2-6 are all checked in order to find the correct result. Currently If i want to search fields 12-6 I need to search each field individually and type in the FILM ID five times.

Yours gratefully
Could you perhaps post an example.
I'm afraid I'm struggling to understand what you're after exactly.
Your last sentence confuses me particularly with a reference to fields 12-6?
Feb 26 '07 #4
Hi

whoops I meant 2-6, sorry.

Before you post your response I just want to say I am aware of Normalisation, I just purely want to know for my knowledge if it is possible for Access to search more than one field for the same information. I created a statement in SQL, however it still asks me for my search criteria for each field 5 times.

Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.*
  2. FROM TABLE1
  3. WHERE (Table1.[Film 1] LIKE '*" & SearchString & "*') " & _
  4.    "OR (Table1.[Film 2] LIKE '*" & SearchString & "*') " & _
  5.    "OR (Table1.[Film 3] LIKE '*" & SearchString & "*') " & _
  6.    "OR (Table1.[Film 4] LIKE '*" & SearchString & "*') " & _
  7.    "OR (Table1.[Film 5] LIKE '*" & SearchString & "*')"
Feb 26 '07 #5
NeoPa
32,556 Expert Mod 16PB
I hear what you're saying and I promise not to post a link to the Normalisation Tutorial ;)
I do still need a clarificatioon of what you're after however.
Let me guess and you can tell me if I'm along the right lines.
Say you had a film Braveheart that you were interested in, you may want to select all those members who have Braveheart in any of their five top film slots? Is that about right?
Feb 26 '07 #6
NeoPa
32,556 Expert Mod 16PB
Hi

whoops I meant 2-6, sorry.

Before you post your response I just want to say I am aware of Normalisation, I just purely want to know for my knowledge if it is possible for Access to search more than one field for the same information. I created a statement in SQL, however it still asks me for my search criteria for each field 5 times.

Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.*
  2. FROM TABLE1
  3. WHERE (Table1.[Film 1] LIKE '*" & SearchString & "*') " & _
  4.    "OR (Table1.[Film 2] LIKE '*" & SearchString & "*') " & _
  5.    "OR (Table1.[Film 3] LIKE '*" & SearchString & "*') " & _
  6.    "OR (Table1.[Film 4] LIKE '*" & SearchString & "*') " & _
  7.    "OR (Table1.[Film 5] LIKE '*" & SearchString & "*')"
How did you create and/or test this.
While doctoring it so that it could be read, I found it was a bit of a hybrid of SQL code & VBA code. It couldn't possibly work as you had it. Can I assume that you have a VBA variable called SearchString?

Try :
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * " & _
  2.          "FROM Table1 " & _
  3.          "WHERE [Film 1] & [Film 2] & [Film 3] & " & _
  4.                "[Film 4] & [Film 5] Like '*" & SearchString & "*'"
Feb 26 '07 #7
Hi

Thank you for your posting

Quote:
Let me guess and you can tell me if I'm along the right lines.
Say you had a film Braveheart that you were interested in, you may want to select all those members who have Braveheart in any of their five top film slots? Is that about right?

Yes!!!!! Perfect thank you!!!!! you understood my query 100 Percent!!!

I tried the code, I created a query and used your code as the SQL behing it. Unfortunately I kept on receiving the result "EXPR1000". I entered your code like this:

SELECT "*"
FROM Table1
WHERE [Film 1] & [Film 2] & [Film 3] & [Film 4] & [Film 5] Like "*" & SearchString & "*'";

I will try to add a copy of the database with this error message. Thank you for helping me!!! I am really pleased that you are willing to help me work out this little problem which I have quite an interest in knowing how to solve.

And thank you for not posing any normalisation tutorials !!! I know the structure is not something that would be used but that isnt what I am interested in.
Feb 26 '07 #8
NeoPa
32,556 Expert Mod 16PB
Hi

Thank you for your posting

Quote:
Let me guess and you can tell me if I'm along the right lines.
Say you had a film Braveheart that you were interested in, you may want to select all those members who have Braveheart in any of their five top film slots? Is that about right?

Yes!!!!! Perfect thank you!!!!! you understood my query 100 Percent!!!

I tried the code, I created a query and used your code as the SQL behing it. Unfortunately I kept on receiving the result "EXPR1000". I entered your code like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT "*"
  2. FROM Table1
  3. WHERE [Film 1] & [Film 2] & [Film 3] & [Film 4] & [Film 5] Like "*" & SearchString & "*'";
I will try to add a copy of the database with this error message. Thank you for helping me!!! I am really pleased that you are willing to help me work out this little problem which I have quite an interest in knowing how to solve.

And thank you for not posing any normalisation tutorials !!! I know the structure is not something that would be used but that isnt what I am interested in.
Your version missed out the leading single-quote.
Feb 26 '07 #9
NeoPa
32,556 Expert Mod 16PB
Your version missed out the leading single-quote.
And now I look more closely, some other problems too.
Try my version as exactly as possible.
Feb 26 '07 #10
Hi

Should the code you provided, be added to the "on update" section of a text box or the "View SQL" section in the QBE pane.

thanks
Feb 26 '07 #11
NeoPa
32,556 Expert Mod 16PB
That depends heavily on what you want it for.
That's what you're supposed to tell me first :D
Feb 26 '07 #12
I would really like to create a form where the one search criteria is entered ie "Terminator" and the Query is sorted on the fly to search the "FILM" fields 2-6
to find and return only those entries. Unfortunately my coding is not too strong so I'll need a little help. I have created the form with an unbound text box labeled FILMENTRY, and a command button labeled FLMBUTTON.The table structure remains as the original example I provided. I need some help with the SQL statement. I tried using some ADO language in the variables section but it isn't working properly.
Feb 26 '07 #13

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

Similar topics

0
by: Phil Powell | last post by:
The table already has a fulltext index and from there I can use the MySQL fulltext search query to get results as well as the relevancy score. The problem I have is that MySQL has a default...
0
by: david liu | last post by:
access 2000 query: here's what i want to do. from an asp page, perform a search on a table in access. i have used sql code in the asp page itself, but i'd rather execute a query in access. i...
4
by: visionstate | last post by:
Hi there, I'm fairly new to access and the way it works and I have been building a relatively simple database. It is basically a database where staff members can search for what training they (or...
31
by: DWolff | last post by:
I'm somewhat new to Access, and have no VB experience at all (except for modifying existing code where obvious). I built a data entry form that works fine. Typically, a client will call in and...
6
by: Robertf987 | last post by:
Hi, I need some help, I would be eternally greatful for any kind person out there to give me any advice. I've created a database for the youth centre. It stores applications for funding. I have...
9
by: lightning | last post by:
Hi all, I'm not very conversant with the vocabulary of Access, so please ask for clarification if necessary... I am trying to build a search form that allows combinations of search terms. For...
1
by: Reef81 | last post by:
Does anyone know a way to have the search parameters displayed in the query or report? For example, if I set up a parameter to search all entries in my table, is there a way to have the search...
1
by: gautam89 | last post by:
Hi everyone... I'm a high school student working on an Access project for a summer internship. I needed your assistance in writing a criteria for a select query. Table1 has the following...
5
by: agarwalsrushti | last post by:
hi, This is my the search code i have tried it works well with the fiels stores as string in the database. But i have stored the qualification and specialization as int in database. Each selected...
13
by: Robertf987 | last post by:
Hi, Yet another thing I need help with I'm affraid. I'll first explain what I want, then I'll try to explain what I have. I'm using Microsoft Access 2000. What I want is to be able to do a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.