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. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Filter for Same Value in Two Fields
There are two fields in my query. "From" and "To". For sake of ease, let's
say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. |
#2
|
|||
|
|||
Filter for Same Value in Two Fields
You stated:
shipped "From" Denver and that show shipped "To" Denver Technically this would mean both values were Denver which might not make much sense if you expected the From and To to be different. Assuming you are viewing your query in design view, you would type "Denver" under the From and To columns. If you want Denver to be in both fields, then "Denver" should be on the same line in the grid. If you want From "OR" To to be Denver, then type Denver on the first line of the criteria under From and the second line under To. -- Duane Hookom Microsoft Access MVP "Dave" wrote: There are two fields in my query. "From" and "To". For sake of ease, let's say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. |
#3
|
|||
|
|||
Filter for Same Value in Two Fields
Okay, let me clarify. I used the word 'and' in the English sense; not as a
Boolean algebra sentence. Second, your solution did not work. What I want to do is generate a list of records that have Denver in the "From" field in addition to records that have Denver in the "To" field. No records will populate both the "To" and the "From" fields with the same city name. "Duane Hookom" wrote: You stated: shipped "From" Denver and that show shipped "To" Denver Technically this would mean both values were Denver which might not make much sense if you expected the From and To to be different. Assuming you are viewing your query in design view, you would type "Denver" under the From and To columns. If you want Denver to be in both fields, then "Denver" should be on the same line in the grid. If you want From "OR" To to be Denver, then type Denver on the first line of the criteria under From and the second line under To. -- Duane Hookom Microsoft Access MVP "Dave" wrote: There are two fields in my query. "From" and "To". For sake of ease, let's say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. |
#4
|
|||
|
|||
Filter for Same Value in Two Fields
On Fri, 27 Nov 2009 10:08:01 -0800, Dave
wrote: There are two fields in my query. "From" and "To". For sake of ease, let's say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. Use OR logic. Create a query based on the table, put "Denver" (or, better, a parameter referencing a control on a form) under From, and the same criterion under To, *on a different line on the query grid*. This will retrieve the record if From is equal to "Denver", or if To is equal to "Denver" (or, for that matter, if both are equal to "Denver"). -- John W. Vinson [MVP] |
#5
|
|||
|
|||
Filter for Same Value in Two Fields
Just puting Denver in the criteria sections does not work. I need to write an
If statement of some kind (ie- If "From" or "To" = Denver Then show). Or an Iif statement (Iif ("From" or "To" = Denver, show, hide). How would I do this? Thanks. "John W. Vinson" wrote: On Fri, 27 Nov 2009 10:08:01 -0800, Dave wrote: There are two fields in my query. "From" and "To". For sake of ease, let's say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. Use OR logic. Create a query based on the table, put "Denver" (or, better, a parameter referencing a control on a form) under From, and the same criterion under To, *on a different line on the query grid*. This will retrieve the record if From is equal to "Denver", or if To is equal to "Denver" (or, for that matter, if both are equal to "Denver"). -- John W. Vinson [MVP] . |
#6
|
|||
|
|||
Filter for Same Value in Two Fields
Enter "Denver" on the first criteria line under the To field.
Enter "Denver" on the second criteria line under the From field. John Spencer Access MVP 2002-2005, 2007-2009 The Hilltop Institute University of Maryland Baltimore County Dave wrote: Okay, let me clarify. I used the word 'and' in the English sense; not as a Boolean algebra sentence. Second, your solution did not work. What I want to do is generate a list of records that have Denver in the "From" field in addition to records that have Denver in the "To" field. No records will populate both the "To" and the "From" fields with the same city name. "Duane Hookom" wrote: You stated: shipped "From" Denver and that show shipped "To" Denver Technically this would mean both values were Denver which might not make much sense if you expected the From and To to be different. Assuming you are viewing your query in design view, you would type "Denver" under the From and To columns. If you want Denver to be in both fields, then "Denver" should be on the same line in the grid. If you want From "OR" To to be Denver, then type Denver on the first line of the criteria under From and the second line under To. -- Duane Hookom Microsoft Access MVP "Dave" wrote: There are two fields in my query. "From" and "To". For sake of ease, let's say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. |
#7
|
|||
|
|||
Filter for Same Value in Two Fields
Assumption: You have two fields (From and To) in the record and both From and
To have a value. If that is true you should be able to do as noted in earlier replies. You could use Field: IIF([From] = "Denver" OR [To] = "Denver",True, False) Criteria: True That is doing it the hard way. John Spencer Access MVP 2002-2005, 2007-2009 The Hilltop Institute University of Maryland Baltimore County Dave wrote: Just puting Denver in the criteria sections does not work. I need to write an If statement of some kind (ie- If "From" or "To" = Denver Then show). Or an Iif statement (Iif ("From" or "To" = Denver, show, hide). How would I do this? Thanks. "John W. Vinson" wrote: On Fri, 27 Nov 2009 10:08:01 -0800, Dave wrote: There are two fields in my query. "From" and "To". For sake of ease, let's say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. Use OR logic. Create a query based on the table, put "Denver" (or, better, a parameter referencing a control on a form) under From, and the same criterion under To, *on a different line on the query grid*. This will retrieve the record if From is equal to "Denver", or if To is equal to "Denver" (or, for that matter, if both are equal to "Denver"). -- John W. Vinson [MVP] . |
#8
|
|||
|
|||
Filter for Same Value in Two Fields
On Fri, 27 Nov 2009 12:52:01 -0800, Dave
wrote: Just puting Denver in the criteria sections does not work. I need to write an If statement of some kind (ie- If "From" or "To" = Denver Then show). Or an Iif statement (Iif ("From" or "To" = Denver, show, hide). How would I do this? Thanks. Please define "does not work" - in particular open the query in SQL view and post the SQL here, and indicate what works and what doesn't work. Or, post the relevant fieldnames of your table (From, To, and the fields that you want to show, and any other fields to which you're applying criteria). The OR logic *is the correct solution*, it does work correctly (if done correctly), it does not require any IF or conditional logic. -- John W. Vinson [MVP] |
#9
|
|||
|
|||
Filter for Same Value in Two Fields
Your initial reply did not show up until after my last post. Thank you, the
method you suggested in that post worked. -Dave "John Spencer" wrote: Assumption: You have two fields (From and To) in the record and both From and To have a value. If that is true you should be able to do as noted in earlier replies. You could use Field: IIF([From] = "Denver" OR [To] = "Denver",True, False) Criteria: True That is doing it the hard way. John Spencer Access MVP 2002-2005, 2007-2009 The Hilltop Institute University of Maryland Baltimore County Dave wrote: Just puting Denver in the criteria sections does not work. I need to write an If statement of some kind (ie- If "From" or "To" = Denver Then show). Or an Iif statement (Iif ("From" or "To" = Denver, show, hide). How would I do this? Thanks. "John W. Vinson" wrote: On Fri, 27 Nov 2009 10:08:01 -0800, Dave wrote: There are two fields in my query. "From" and "To". For sake of ease, let's say both these fields are US Cities. How can I pull all the records that show shipped "From" Denver and that show shipped "To" Denver? Thank you in advance. Use OR logic. Create a query based on the table, put "Denver" (or, better, a parameter referencing a control on a form) under From, and the same criterion under To, *on a different line on the query grid*. This will retrieve the record if From is equal to "Denver", or if To is equal to "Denver" (or, for that matter, if both are equal to "Denver"). -- John W. Vinson [MVP] . . |
#10
|
|||
|
|||
Filter for Same Value in Two Fields
On Fri, 27 Nov 2009 14:50:01 -0800, Dave
wrote: Your initial reply did not show up until after my last post. Thank you, the method you suggested in that post worked. And it is the method that I suggested in my response as well, which must have been phrased confusingly... sorry about that, and glad that John Spencer's good advice worked for you! -- John W. Vinson [MVP] |
|
Thread Tools | |
Display Modes | |
|
|