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

Converting an Excel "IF" statement to Access.



 
 
Thread Tools Display Modes
  #1  
Old September 10th, 2007, 03:18 AM posted to microsoft.public.access.forms
timmycav
external usenet poster
 
Posts: 11
Default Converting an Excel "IF" statement to Access.

Hello all,

I'm a bit of an Access novice, so I apologise if questions like this have
been done to detah. I have tried several forums and have, so far, been unable
to find a solution.

In Excel I have been able to create an IF statement to display text in a new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.
  #2  
Old September 10th, 2007, 03:55 AM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default Converting an Excel "IF" statement to Access.

If you are trying to do this in a table, you cannot. But you can do it in a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.



  #3  
Old September 10th, 2007, 04:44 AM posted to microsoft.public.access.forms
timmycav
external usenet poster
 
Posts: 11
Default Converting an Excel "IF" statement to Access.

Hi Arvin,

Thanks for your help. I was trying this in a form, and had attepmted it in a
query also. I tried it with your suggested formula but only got blank fields
after running it.

Any further ideas?

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.




  #4  
Old September 10th, 2007, 08:48 AM posted to microsoft.public.access.forms
Maurice
external usenet poster
 
Posts: 1,585
Default Converting an Excel "IF" statement to Access.

Maybe a stupid question but you did replace the fieldnames that Arvin
presented with your own table-fieldnames?
--
Maurice Ausum


"timmycav" wrote:

Hi Arvin,

Thanks for your help. I was trying this in a form, and had attepmted it in a
query also. I tried it with your suggested formula but only got blank fields
after running it.

Any further ideas?

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.




  #5  
Old September 10th, 2007, 10:53 AM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default Converting an Excel "IF" statement to Access.

If you have not seen errors, the expression was correct so the answer lies
in the data.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"timmycav" wrote in message
...
Hi Arvin,

Thanks for your help. I was trying this in a form, and had attepmted it in
a
query also. I tried it with your suggested formula but only got blank
fields
after running it.

Any further ideas?

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in
a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this
have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in
a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.






  #6  
Old September 10th, 2007, 11:34 PM posted to microsoft.public.access.forms
timmycav
external usenet poster
 
Posts: 11
Default Converting an Excel "IF" statement to Access.

Hi Maurice,

Yep. Made sure I had the correct field names.

"Maurice" wrote:

Maybe a stupid question but you did replace the fieldnames that Arvin
presented with your own table-fieldnames?
--
Maurice Ausum


"timmycav" wrote:

Hi Arvin,

Thanks for your help. I was trying this in a form, and had attepmted it in a
query also. I tried it with your suggested formula but only got blank fields
after running it.

Any further ideas?

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.



  #7  
Old September 10th, 2007, 11:34 PM posted to microsoft.public.access.forms
timmycav
external usenet poster
 
Posts: 11
Default Converting an Excel "IF" statement to Access.

Thanks Arvin.

I will have a further look at the data.

"Arvin Meyer [MVP]" wrote:

If you have not seen errors, the expression was correct so the answer lies
in the data.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"timmycav" wrote in message
...
Hi Arvin,

Thanks for your help. I was trying this in a form, and had attepmted it in
a
query also. I tried it with your suggested formula but only got blank
fields
after running it.

Any further ideas?

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in
a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this
have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in
a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.






  #8  
Old September 11th, 2007, 05:02 AM posted to microsoft.public.access.forms
timmycav
external usenet poster
 
Posts: 11
Default Converting an Excel "IF" statement to Access.

Arvin,

I have checked the data and it all appears fine. Would the fact that the
firleds in the form are formatted as currency have any affect on the way the
formula works?

TC

"timmycav" wrote:

Thanks Arvin.

I will have a further look at the data.

"Arvin Meyer [MVP]" wrote:

If you have not seen errors, the expression was correct so the answer lies
in the data.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"timmycav" wrote in message
...
Hi Arvin,

Thanks for your help. I was trying this in a form, and had attepmted it in
a
query also. I tried it with your suggested formula but only got blank
fields
after running it.

Any further ideas?

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in
a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this
have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in
a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.






  #9  
Old September 11th, 2007, 06:10 AM posted to microsoft.public.access.forms
timmycav
external usenet poster
 
Posts: 11
Default Converting an Excel "IF" statement to Access.

Arvin,

Sorry to keep asking questions. Is this formula meant to be in the
expression builder or in visual basic? I have no knowledge of Visual Basic.
the current info in Visual Basic follows:
Private Sub Current_Level_BeforeUpdate(Cancel As Integer)

End Sub

Do I enter the formula in here with the current text, or do I replace the
current text completely?

Thanks again.

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.




  #10  
Old September 11th, 2007, 07:16 AM posted to microsoft.public.access.forms
Steve Sanford
external usenet poster
 
Posts: 190
Default Converting an Excel "IF" statement to Access.

As a check of the data, create a new query. Switch to SQL vies and paste in
the following:

SELECT [01 Program Table].[Spend (Total)], IIf([01 Program Table]![Spend
(Total)]100000,"Gold",IIf([01 Program Table]![Spend
(Total)]5000,"Zirconia","Titanium")) AS TheLevel FROM [01 Program Table];


Now run the query. Do the levels match up with the values?

Note: 100000.0001 will be "Gold" and 100000 will be "Zirconia".


Putting the IIF() statement in a query makes it a "field" that you can use
as a control source for a control on a form.


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


"timmycav" wrote:

Arvin,

I have checked the data and it all appears fine. Would the fact that the
firleds in the form are formatted as currency have any affect on the way the
formula works?

TC

"timmycav" wrote:

Thanks Arvin.

I will have a further look at the data.

"Arvin Meyer [MVP]" wrote:

If you have not seen errors, the expression was correct so the answer lies
in the data.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"timmycav" wrote in message
...
Hi Arvin,

Thanks for your help. I was trying this in a form, and had attepmted it in
a
query also. I tried it with your suggested formula but only got blank
fields
after running it.

Any further ideas?

"Arvin Meyer [MVP]" wrote:

If you are trying to do this in a table, you cannot. But you can do it in
a
query, or in a form or report. In a query:

Expr1: IIf([TableName].[FieldName]100000, "Gold",
IIf([TableName].[FieldName]5000, "Zirconia", "Titanium"))
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

"timmycav" wrote in message
...
Hello all,

I'm a bit of an Access novice, so I apologise if questions like this
have
been done to detah. I have tried several forums and have, so far, been
unable
to find a solution.

In Excel I have been able to create an IF statement to display text in
a
new
cell when a particular number value appears in another cell:
=IF(X2100000,"Gold",IF(X25000,"Zirconia",IF(X25 000,"Titanium")))

I have tried converting this to an Access IIF statement in a form, but
have
had no luck.
=IIf([01 Program Table]![Spend (Total)]100000,"Gold",IIf([01 Program
Table]![Spend (Total)]5000,"Zirconia",IIf([01 Program Table]![Spend
(Total)]5000,"Titanium")))

I would be grateful for any assistance anyone can provide.






 




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 03:38 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.