A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

1 Field and 2 Criteria



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2009, 03:24 PM posted to microsoft.public.access.queries
Jace
external usenet poster
 
Posts: 9
Default 1 Field and 2 Criteria

I'm new to Access but very fluent in Excel so bare with me on this.

What I have is a query I'm trying to create where I have a Problem
Code(numeric) and a Fix Code(numberic). Each of these codes have a Long
Description in a table just for these codes. However, this table has several
"TABL"'s within it. To get descriptions for a Problem Code the TABL field
must equal "101". To get descriptions for a Fix Code the TABL field must
equal "303". This is a problem because when I write the query I have each
code read out on a row but I can only assign TABL to either 101 or 303 and
Long Description will show up twice with the same description.

This is basically what my query looks like right now:

SELECT C.ACCOUNT, W.PROBCODE, D.LONGDESC, W.FIXCODE, D.LONGDESC
FROM CUSTOMER AS C, WORKORDER AS W, DESCTABLES AS D
WHERE D.TABL = "101"

But instead of getting a Problem Code desctiption and a Fix Code description
I get 2 Problem Code descriptions.
  #2  
Old December 18th, 2009, 04:18 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default 1 Field and 2 Criteria

You have to join the tables in the query. Customer must be joined to
Workorder table.

I could do more than guess if I saw a sample of your data but try this --
SELECT C.ACCOUNT, W.PROBCODE, D.LONGDESC, W.FIXCODE, D.TABL, D.LONGDESC
FROM CUSTOMER AS C INNER JOIN WORKORDER AS W ON W.ACCOUNT = C.ACCOUNT,
DESCTABLES AS D
WHERE W.FIXCODE = D.FIXCODE OR W.PROBCODE = D.PROBCODE
ORDER BY C.ACCOUNT, W.PROBCODE, D.TABL;

--
Build a little, test a little.


"jace" wrote:

I'm new to Access but very fluent in Excel so bare with me on this.

What I have is a query I'm trying to create where I have a Problem
Code(numeric) and a Fix Code(numberic). Each of these codes have a Long
Description in a table just for these codes. However, this table has several
"TABL"'s within it. To get descriptions for a Problem Code the TABL field
must equal "101". To get descriptions for a Fix Code the TABL field must
equal "303". This is a problem because when I write the query I have each
code read out on a row but I can only assign TABL to either 101 or 303 and
Long Description will show up twice with the same description.

This is basically what my query looks like right now:

SELECT C.ACCOUNT, W.PROBCODE, D.LONGDESC, W.FIXCODE, D.LONGDESC
FROM CUSTOMER AS C, WORKORDER AS W, DESCTABLES AS D
WHERE D.TABL = "101"

But instead of getting a Problem Code desctiption and a Fix Code description
I get 2 Problem Code descriptions.

  #3  
Old December 20th, 2009, 11:01 PM posted to microsoft.public.access.queries
Jace
external usenet poster
 
Posts: 9
Default 1 Field and 2 Criteria

Thanks for the reply. I don't know that this will work how I need but that's
probably like you said because I can't provide sample data. I'm thinking
what I will do is just make 2 new tables, 1 for Problem Codes and 1 for Fix
Codes. Again thanks for your response and help.

"KARL DEWEY" wrote:

You have to join the tables in the query. Customer must be joined to
Workorder table.

I could do more than guess if I saw a sample of your data but try this --
SELECT C.ACCOUNT, W.PROBCODE, D.LONGDESC, W.FIXCODE, D.TABL, D.LONGDESC
FROM CUSTOMER AS C INNER JOIN WORKORDER AS W ON W.ACCOUNT = C.ACCOUNT,
DESCTABLES AS D
WHERE W.FIXCODE = D.FIXCODE OR W.PROBCODE = D.PROBCODE
ORDER BY C.ACCOUNT, W.PROBCODE, D.TABL;

--
Build a little, test a little.


"jace" wrote:

I'm new to Access but very fluent in Excel so bare with me on this.

What I have is a query I'm trying to create where I have a Problem
Code(numeric) and a Fix Code(numberic). Each of these codes have a Long
Description in a table just for these codes. However, this table has several
"TABL"'s within it. To get descriptions for a Problem Code the TABL field
must equal "101". To get descriptions for a Fix Code the TABL field must
equal "303". This is a problem because when I write the query I have each
code read out on a row but I can only assign TABL to either 101 or 303 and
Long Description will show up twice with the same description.

This is basically what my query looks like right now:

SELECT C.ACCOUNT, W.PROBCODE, D.LONGDESC, W.FIXCODE, D.LONGDESC
FROM CUSTOMER AS C, WORKORDER AS W, DESCTABLES AS D
WHERE D.TABL = "101"

But instead of getting a Problem Code desctiption and a Fix Code description
I get 2 Problem Code descriptions.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:19 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.