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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional Moves



 
 
Thread Tools Display Modes
  #1  
Old August 15th, 2007, 09:24 PM posted to microsoft.public.access
Bunky
external usenet poster
 
Posts: 374
Default 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  
Old August 15th, 2007, 09:52 PM posted to microsoft.public.access
Steven Chicago,Illinois
external usenet poster
 
Posts: 60
Default 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  
Old August 15th, 2007, 10:00 PM posted to microsoft.public.access
Bunky
external usenet poster
 
Posts: 374
Default 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  
Old August 15th, 2007, 10:12 PM posted to microsoft.public.access
Bunky
external usenet poster
 
Posts: 374
Default 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  
Old August 15th, 2007, 10:16 PM posted to microsoft.public.access
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default 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  
Old August 15th, 2007, 10:20 PM posted to microsoft.public.access
Bunky
external usenet poster
 
Posts: 374
Default 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  
Old August 15th, 2007, 10:34 PM posted to microsoft.public.access
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default 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  
Old August 15th, 2007, 10:44 PM posted to microsoft.public.access
Bunky
external usenet poster
 
Posts: 374
Default 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  
Old August 15th, 2007, 10:56 PM posted to microsoft.public.access
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default 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  
Old August 17th, 2007, 01:44 AM posted to microsoft.public.access
Wayne-I-M
external usenet poster
 
Posts: 3,674
Default 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

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:47 AM.


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