IF statement in a Query

G

Guest

I need to know how to set up an embedded IF statement in a query where I have
a table with Manufacture Cat # (field) that needs to be populated if two
fields are equal (Manufacture Name and Vendor Name). Then it should populate
the Manufacture Cat # (field) from the Vendor Cat # (field)????? I hope this
makes enough sense to get some help, I am struggling with this badly.
 
J

Jeff L

Do an update query for this.
Update YourTable
Set [Manufacture Cat #] = [Vendor Cat #]
Where [Manufacture Name] = [Vendor Name]

Hope that helps!
 
G

Guest

Does this, Set [Manufacture Cat #] = [VEN-ITEM] Where [Manufacture Name] =
[VENDOR-SNAME] go in the "update to" row under the Manufacture Cat #, field?
If so this did not work. Maybe I am not putting it in the right place? Or
setting it up correctly.
--
Thomas


Jeff L said:
Do an update query for this.
Update YourTable
Set [Manufacture Cat #] = [Vendor Cat #]
Where [Manufacture Name] = [Vendor Name]

Hope that helps!


T said:
I need to know how to set up an embedded IF statement in a query where I have
a table with Manufacture Cat # (field) that needs to be populated if two
fields are equal (Manufacture Name and Vendor Name). Then it should populate
the Manufacture Cat # (field) from the Vendor Cat # (field)????? I hope this
makes enough sense to get some help, I am struggling with this badly.
 
D

David F Cox

The IIF function seems to be what you want.
IIF( argtest, arg_result if true, arg_result_if_false)

maybe something like:

IIF([Manufacture Name] = [Vendor Name], [vendor cat#], [Manufacture Cat #])
 
G

Guest

Also,

In the query I tried an IIF statement, but something is missing,

IIF(is null[Manufacture Cat #]),IIF( [VENDOR-SNAME] = [Manufacture Name] ,
[VEN-ITEM] )

If I want the outcome to be fill the [Manufacture Cat #] field from the
[VEN-ITEM] field.
--
Thomas


T Miller said:
Does this, Set [Manufacture Cat #] = [VEN-ITEM] Where [Manufacture Name] =
[VENDOR-SNAME] go in the "update to" row under the Manufacture Cat #, field?
If so this did not work. Maybe I am not putting it in the right place? Or
setting it up correctly.
--
Thomas


Jeff L said:
Do an update query for this.
Update YourTable
Set [Manufacture Cat #] = [Vendor Cat #]
Where [Manufacture Name] = [Vendor Name]

Hope that helps!


T said:
I need to know how to set up an embedded IF statement in a query where I have
a table with Manufacture Cat # (field) that needs to be populated if two
fields are equal (Manufacture Name and Vendor Name). Then it should populate
the Manufacture Cat # (field) from the Vendor Cat # (field)????? I hope this
makes enough sense to get some help, I am struggling with this badly.
 
G

Guest

David,

Why did this not work then??

IIF(is null[Manufacture Cat #]),IIF( [VENDOR-SNAME] = [Manufacture Name] ,
[VEN-ITEM] )

--
Thomas


David F Cox said:
The IIF function seems to be what you want.
IIF( argtest, arg_result if true, arg_result_if_false)

maybe something like:

IIF([Manufacture Name] = [Vendor Name], [vendor cat#], [Manufacture Cat #])
 
G

Guest

David,

Now I need to update a table with the exp. that you helped me create. I
tried to use and update query but because it is an exp it won't work. How do
I get the data in the query exp. field to add to the table that I am using so
that it will update the Manufacture Cat # field in my main table?
--
Thomas


T Miller said:
David,

Why did this not work then??

IIF(is null[Manufacture Cat #]),IIF( [VENDOR-SNAME] = [Manufacture Name] ,
[VEN-ITEM] )

--
Thomas


David F Cox said:
The IIF function seems to be what you want.
IIF( argtest, arg_result if true, arg_result_if_false)

maybe something like:

IIF([Manufacture Name] = [Vendor Name], [vendor cat#], [Manufacture Cat #])

T Miller said:
I need to know how to set up an embedded IF statement in a query where I
have
a table with Manufacture Cat # (field) that needs to be populated if two
fields are equal (Manufacture Name and Vendor Name). Then it should
populate
the Manufacture Cat # (field) from the Vendor Cat # (field)????? I hope
this
makes enough sense to get some help, I am struggling with this badly.
 
T

Tom Lake

T Miller said:
David,

Why did this not work then??

IIF(is null[Manufacture Cat #]),IIF( [VENDOR-SNAME] = [Manufacture Name] ,
[VEN-ITEM] )

You need a second condition for the second IIf. Right now you don't tell
it what to do if [VENDOR-NAME] <> [Manufacture Name].

Tom Lake
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top