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
|
|||
|
|||
Conditional Moves
I have two inputs that I want to join using queries. Normally, no problem
but I would like to have a conditional move. ie. I want to move field1 to field2 if fielda = fieldb. How do I attack this? Thanks again. |
#2
|
|||
|
|||
Conditional Moves
Dear Bunky,
In your query have a field that is a expression.The field gets it's value through a IIF statement that determines which input field to use as the value for that expression. Below is a example of a expression that I used: Expression2: IIf([fielda]=[fieldb],[field1],[field2]) If the fielda=fieldb, then output field1 else output field2 as the value of Expression2 Expression2 could also be the new name of field2 Of course the source for this query must have field1 and field2 and fielda and fieldb available. Hope that helps jump start your project, Steve |
#3
|
|||
|
|||
Conditional Moves
Thank you, Steven.
That works. "Steven Chicago,Illinois" wrote: Dear Bunky, In your query have a field that is a expression.The field gets it's value through a IIF statement that determines which input field to use as the value for that expression. Below is a example of a expression that I used: Expression2: IIf([fielda]=[fieldb],[field1],[field2]) If the fielda=fieldb, then output field1 else output field2 as the value of Expression2 Expression2 could also be the new name of field2 Of course the source for this query must have field1 and field2 and fielda and fieldb available. Hope that helps jump start your project, Steve |
#4
|
|||
|
|||
Conditional Moves
One more thing, Steven.
How would I say If fieldA = fieldB, move field1 to field2 else move field3 to field2. Sorry to trouble you again, but the syntax is giving me fits. Thanks "Bunky" wrote: Thank you, Steven. That works. "Steven Chicago,Illinois" wrote: Dear Bunky, In your query have a field that is a expression.The field gets it's value through a IIF statement that determines which input field to use as the value for that expression. Below is a example of a expression that I used: Expression2: IIf([fielda]=[fieldb],[field1],[field2]) If the fielda=fieldb, then output field1 else output field2 as the value of Expression2 Expression2 could also be the new name of field2 Of course the source for this query must have field1 and field2 and fielda and fieldb available. Hope that helps jump start your project, Steve |
#5
|
|||
|
|||
Conditional Moves
Hi
Are you working on a form or a query ? It sound like you're on a form -- Wayne Manchester, England. "Bunky" wrote: I have two inputs that I want to join using queries. Normally, no problem but I would like to have a conditional move. ie. I want to move field1 to field2 if fielda = fieldb. How do I attack this? Thanks again. |
#6
|
|||
|
|||
Conditional Moves
Hi Wayne!
Nope, Working on a query in design form. "Wayne-I-M" wrote: Hi Are you working on a form or a query ? It sound like you're on a form -- Wayne Manchester, England. "Bunky" wrote: I have two inputs that I want to join using queries. Normally, no problem but I would like to have a conditional move. ie. I want to move field1 to field2 if fielda = fieldb. How do I attack this? Thanks again. |
#7
|
|||
|
|||
Conditional Moves
Am a little confused by this
Field2:IIf ( [TableName]![FieldA] = [TableName]![FieldB] , [TableName ]![Field1] , [TableName]![Field3] ) Do you already have a field called Field2 if so - what is in it. You may need to UpdateQuery this if there is something in the field that you want to replace. In this case the above would not work - you need to set the criteria and then Update. But as I can't your query I can't give other advice without more info You should use the full TableName and FieldName in calculations - sooner or later you will want to find out where the results come from and if you use the full details it will be much simpler. Good luck -- Wayne Manchester, England. "Bunky" wrote: Hi Wayne! Nope, Working on a query in design form. "Wayne-I-M" wrote: Hi Are you working on a form or a query ? It sound like you're on a form -- Wayne Manchester, England. "Bunky" wrote: I have two inputs that I want to join using queries. Normally, no problem but I would like to have a conditional move. ie. I want to move field1 to field2 if fielda = fieldb. How do I attack this? Thanks again. |
#8
|
|||
|
|||
Conditional Moves
Wayne,
I am writing an expression in a query in design view. GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints]) This works fine but I do not have the else condition just the true condition I want it to say something like this GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints] else [points],[sumofpoints) I know the syntax is wrong but I do not know what the right syntax would be. Sorry I was not clear and thank you for your assistance. "Wayne-I-M" wrote: Am a little confused by this Field2:IIf ( [TableName]![FieldA] = [TableName]![FieldB] , [TableName ]![Field1] , [TableName]![Field3] ) Do you already have a field called Field2 if so - what is in it. You may need to UpdateQuery this if there is something in the field that you want to replace. In this case the above would not work - you need to set the criteria and then Update. But as I can't your query I can't give other advice without more info You should use the full TableName and FieldName in calculations - sooner or later you will want to find out where the results come from and if you use the full details it will be much simpler. Good luck -- Wayne Manchester, England. "Bunky" wrote: Hi Wayne! Nope, Working on a query in design form. "Wayne-I-M" wrote: Hi Are you working on a form or a query ? It sound like you're on a form -- Wayne Manchester, England. "Bunky" wrote: I have two inputs that I want to join using queries. Normally, no problem but I would like to have a conditional move. ie. I want to move field1 to field2 if fielda = fieldb. How do I attack this? Thanks again. |
#9
|
|||
|
|||
Conditional Moves
GoodPts: If ( ([ StartAttWeek] = [ AttendWeek] And [ StartAttYear] = [
AttendYear] ) , [ startpoints] , [ sumofpoints] ) I have taken out the table names for clarity. BUT I don't think this will work? Where are you getting the SumOfPoints (is this a subquery). Do you have a year field for the Start and another for year Attend ?? You may be better not to use a year but simply use a time/date field in the table. I think you may need t look at how the tables and querys are built. -- Wayne Manchester, England. "Bunky" wrote: Wayne, I am writing an expression in a query in design view. GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints]) This works fine but I do not have the else condition just the true condition I want it to say something like this GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints] else [points],[sumofpoints) I know the syntax is wrong but I do not know what the right syntax would be. Sorry I was not clear and thank you for your assistance. "Wayne-I-M" wrote: Am a little confused by this Field2:IIf ( [TableName]![FieldA] = [TableName]![FieldB] , [TableName ]![Field1] , [TableName]![Field3] ) Do you already have a field called Field2 if so - what is in it. You may need to UpdateQuery this if there is something in the field that you want to replace. In this case the above would not work - you need to set the criteria and then Update. But as I can't your query I can't give other advice without more info You should use the full TableName and FieldName in calculations - sooner or later you will want to find out where the results come from and if you use the full details it will be much simpler. Good luck -- Wayne Manchester, England. "Bunky" wrote: Hi Wayne! Nope, Working on a query in design form. "Wayne-I-M" wrote: Hi Are you working on a form or a query ? It sound like you're on a form -- Wayne Manchester, England. "Bunky" wrote: I have two inputs that I want to join using queries. Normally, no problem but I would like to have a conditional move. ie. I want to move field1 to field2 if fielda = fieldb. How do I attack this? Thanks again. |
#10
|
|||
|
|||
Conditional Moves
can you post the table and field names
-- Wayne Manchester, England. "Bunky" wrote: Good Morning Wayne, GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints]) This is a query that is using data from several subqueries. The names StartAttWeek & Year / AttendWeek & Yr represents an interval week and yr formated like '0722' for a week ending date of 06/02/07. But all this is not relevant to my problem. I want a query expression to say GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints] ELSE do something else like the field points to the field sumofpoints) Sorry if I am not being specific enough. Thanks, "Wayne-I-M" wrote: GoodPts: If ( ([ StartAttWeek] = [ AttendWeek] And [ StartAttYear] = [ AttendYear] ) , [ startpoints] , [ sumofpoints] ) I have taken out the table names for clarity. BUT I don't think this will work? Where are you getting the SumOfPoints (is this a subquery). Do you have a year field for the Start and another for year Attend ?? You may be better not to use a year but simply use a time/date field in the table. I think you may need t look at how the tables and querys are built. -- Wayne Manchester, England. "Bunky" wrote: Wayne, I am writing an expression in a query in design view. GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints]) This works fine but I do not have the else condition just the true condition I want it to say something like this GoodPts: IIf([StartAttWeek & Year]=[AttendWeek & Year],[startpoints],[sumofpoints] else [points],[sumofpoints) I know the syntax is wrong but I do not know what the right syntax would be. Sorry I was not clear and thank you for your assistance. "Wayne-I-M" wrote: Am a little confused by this Field2:IIf ( [TableName]![FieldA] = [TableName]![FieldB] , [TableName ]![Field1] , [TableName]![Field3] ) Do you already have a field called Field2 if so - what is in it. You may need to UpdateQuery this if there is something in the field that you want to replace. In this case the above would not work - you need to set the criteria and then Update. But as I can't your query I can't give other advice without more info You should use the full TableName and FieldName in calculations - sooner or later you will want to find out where the results come from and if you use the full details it will be much simpler. Good luck -- Wayne Manchester, England. "Bunky" wrote: Hi Wayne! Nope, Working on a query in design form. "Wayne-I-M" wrote: Hi Are you working on a form or a query ? It sound like you're on a form -- Wayne Manchester, England. "Bunky" wrote: I have two inputs that I want to join using queries. Normally, no problem but I would like to have a conditional move. ie. I want to move field1 to field2 if fielda = fieldb. How do I attack this? Thanks again. |
|
Thread Tools | |
Display Modes | |
|
|