473,480 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I restrict my results?

Hello. I have my data setup as follows:

Main
MEMNAME NAME TYPE LABEL

Variable
MEMNAME VARNAME NUMBER

Format
MEMNAME FMTVALUE NUMBER

The MEMNAME variable is the source dataset. The 3 tables are linked by
MEMNAME and MAIN.NAME -->Variable.VARNAME --> Variable.NUMBER-->
Format.NUMBER.

Now I have a query that will search the Main table and return the value
based on a "Like" query. I have a subquery that will display the
format for that variable. The problem is that I can't get it so that
the subquery only displays the FMTVALUE if it matched by name **AND BY
MEMNAME**

Here is a screenshot of results:
http://www.mindspring.com/~a.pavluck/access.JPG

Nov 13 '05 #1
7 3223
Well for starters, lets rename ALL your tables and fields. "Variable",
"Format", "Number", etc. are all reserved words in Access/VBA that means
something and should NOT be used as object names. You're courting disaster
(or at very least deep confusion) by using them for your own names. Try
something like:

tblSurvey (old "Main")
SurveyID -autonumber (primary key)
Memname - text (whatever this is)
SurveyName - text (old "Name")
MyType -text (old "Char")
etc.

tblAnswers
AnswerID - number (0-99) or text (A-ZZ) your choice -primary key
AnswerDescription - text

tblResults
ResultID -autonumber -primary key
SurveyID -foreign key (related to tblSurvey)
AnswerID -foreign key (related to tblAnswers)
ResultDate
etc.

A normalized database eliminates repeating groups and redundant data and
then makes each record dependant on the key.

Now to answer your question: Look at the Access help for the "Like"
operator syntax. You'll need something like:

Like("myText*")

-Ed

"Alex L Pavluck" <ap******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hello. I have my data setup as follows:

Main
MEMNAME NAME TYPE LABEL

Variable
MEMNAME VARNAME NUMBER

Format
MEMNAME FMTVALUE NUMBER

The MEMNAME variable is the source dataset. The 3 tables are linked by
MEMNAME and MAIN.NAME -->Variable.VARNAME --> Variable.NUMBER-->
Format.NUMBER.

Now I have a query that will search the Main table and return the value
based on a "Like" query. I have a subquery that will display the
format for that variable. The problem is that I can't get it so that
the subquery only displays the FMTVALUE if it matched by name **AND BY
MEMNAME**

Here is a screenshot of results:
http://www.mindspring.com/~a.pavluck/access.JPG

Nov 13 '05 #2
First of all, get rid of the Varname rubbish. Assign at least
meaningful names to primary keys and foreign keys. Why do you need a
subquery at all? Why not join the two tables?
I think this is only hard because you're making it that way...

Nov 13 '05 #3
I used these names just to illustrate the problem. If you don't have a
solution to provide then please don't respond.

Again the problem is that I need to build a sub-query that will join on
*2* variables not just 1 from the master and child.

Nov 13 '05 #4
The point is, you won't get any responses if you insist on your own
confusing terminology as no one will understand what you want. The fact
that you want to filter on two fields (not "variables", by the way -those
are values held in memory) whose values are identical suggests that your
data is not structured and related correctly - as I tried to point out.

But ignoring all that, to set the query criteria you request, use the AND
operator.
An example, using data from two separate table to filter data in a third :

SELECT tblAgencies.Agency, tblAgencies.AgencyID
FROM tblAgencies, tblAgencyDonation, tblAgencyPledge
WHERE (((tblAgencies.AgencyID)=[tblAgencyDonation].[AgencyID] AND
(tblAgencies.AgencyID)=[tblAgencyPledge].[AgencyID]));
The SQL to get the same result from three related tables:

SELECT tblAgencies.Agency, tblAgencies.AgencyID
FROM (tblAgencies INNER JOIN tblAgencyDonation ON tblAgencies.AgencyID =
tblAgencyDonation.AgencyID) INNER JOIN tblAgencyPledge ON
tblAgencies.AgencyID = tblAgencyPledge.AgencyID;

-Ed

"Alex L Pavluck" <ap******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I used these names just to illustrate the problem. If you don't have a
solution to provide then please don't respond.

Again the problem is that I need to build a sub-query that will join on
*2* variables not just 1 from the master and child.

Nov 13 '05 #5
Ok, your point is well taken.

I can not figure out how to view my subquery in SQL. I have a query
and I used the insert menu to insert a subquery (which is just another
query). At that time it asked to to link the query results with 1
variable. That is the problem, I need to link on 2 variables.

Nov 13 '05 #6
Here is the solution for anyone who is interested:

Modify Subdatasheet:
Note If you want to specify two or more fields in the Link Child
Fields or Link Master Fields box, enter the field names separated by a
semicolon (;)- for example, Last Name;First Name.

Nov 13 '05 #7
I think we're still confused.

The http://www.mindspring.com/~a.pavluck/access.JPG
image you sent shows a TABLE in datasheet view with a SUBDATASHEET open.
This is an Access "feature" that lets you link data tables for viewing in
this spreadsheet style view. Nearly all developers and good applications
ignore this feature (for good reasons) and depend on well designed forms
(based on queries) to show related information.

Contrast that to a QUERY which is a dataset of one or more related tables
and/or other queries. It allows you to filter and sort (Select query) and
add records (Append query), Update, etc. Open/create a new query in design
mode. Add the tables or (queries) you want; create links (joins) between
them by drag & drop of the related fields.
Enter the filter criteria and/or sort order you need. View the generated
SQL statement or datasheet results by using the View menu. If all this is
strange to you, use the query wizard and read through the Access Help to get
you started in query design.

If you still need/want your linked subdatasheet,(and I can't recommend it)
then link to your new query that has already done the selection on multiple
criteria/ that you needed.

Good luck
-Ed
"Alex L Pavluck" <ap******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Ok, your point is well taken.

I can not figure out how to view my subquery in SQL. I have a query
and I used the insert menu to insert a subquery (which is just another
query). At that time it asked to to link the query results with 1
variable. That is the problem, I need to link on 2 variables.

Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
6382
by: gc | last post by:
Hi, What is the purpose of the restrict keyword? gc
4
2167
by: Vijay Kumar R Zanvar | last post by:
Greetings, Are the following inferences of mine correct? 1. #include <string.h> char *strcpy(char * restrict s1, const char * restrict s2); a. s1 != s2 b. That means,
7
2652
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory...
12
2465
by: Me | last post by:
I'm trying to wrap my head around the wording but from what I think the standard says: 1. it's impossible to swap a restrict pointer with another pointer, i.e. int a = 1, b = 2; int *...
21
6462
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no...
1
1180
by: dananrg | last post by:
If I want to restrict search results by country, what precisely do I need to include in searchTerm variable below? I've tried: searchTerm = 'restrict:countryUS blah blah' searchTerm =...
5
8184
by: Dakrat | last post by:
Allow me to preface this post by saying that this is my first database project, and while I have learned a lot, any concepts I have learned are hit and miss as I have found new requirements and...
2
3241
by: venkat | last post by:
Hi, i came across restrict qualifier while looking the code. I haven't able to understand what does this do?. Can some one help me how does this makes the things restrict to an specified...
0
2961
by: copx | last post by:
Restrict keyword questions How far does the guarantee that an object is not accessed through another pointer go? I mean, all examples I have seen are simple stuff like: int f (int *restrict x,...
23
4793
by: raashid bhatt | last post by:
what is restrict keyword used for? eg int *restrict p;
0
7033
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
7027
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,...
1
6726
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
6861
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
5318
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4763
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...
0
4468
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...
0
2974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1291
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 ...

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.