Place a value in one field based upon the value of another field

creyn

Board Regular
Joined
Sep 16, 2016
Messages
127
How can I write in the query if one field is "Yes" have another field = "" or if the field is "" then have another field = "No"?

I tried this:

=IIf([PQRS Data].Value = "Yes", [PQRS Data].Problems = "", "No")


This does not work. Can anyone assist me with clearing this up?

Thank you
 
The field, [PQRS Data].Problems needs to be Updated to blank("") if the field, [PQRS Data].Value = "Reporting Met And Performance Met" Or [PQRS Data].Value = "Advanced Care Planning - first 30 minutes" Or [PQRS Data].Value = "Advanced Care Planning - each additional 30 minutes.
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Then it should be just as simple as:
Code:
UPDATE [PQRS Data] SET [PQRS Data].Problems = ""
WHERE ([PQRS Data].Value="Reporting Met And Performance Met")
OR ([PQRS Data].Value="Advanced Care Planning - first 30 minutes")
OR ([PQRS Data].Value)="Advanced Care Planning - each additional 30 minutes");
 
Upvote 0
Thanks. Will this work also?

UPDATE [PQRS Data] SET [PQRS Data].Problems = ""
WHERE ([PQRS Data].Value="Reporting Met And Performance Met")
OR ([PQRS Data].Value="Advanced Care Planning - first 30 minutes")
OR ([PQRS Data].Value)="Advanced Care Planning - each additional 30 minutes");
FROM
(
SELECT [PQRS Data].[Chart #] AS [Patient ID],
[PQRS Data].[Admit Dt] AS DOS,
[PQRS Data].[Visit ID],
=IIf([PQRS Data].Value = "Reporting Met And Performance Met" Or [PQRS Data].Value = "Advanced Care Planning - first 30 minutes" Or [PQRS Data].Value = "Advanced Care Planning - each additional 30 minutes", "Yes","") AS Met,
[PQRS Data].Problems,
"N/A" AS Excluded
FROM [PQRS Data]
GROUP BY [PQRS Data].[Chart #], [PQRS Data].[Admit Dt], [PQRS Data].[Visit ID], [PQRS Data].Problems, "N/A", [PQRS Data].Value;
) t
WHERE [PQRS Data].Problems = t.Problems
 
Upvote 0
Why do you want to add all that other stuff to the query?
What is the purpose of doing so?
Are you trying to add more criteria by doing that?
 
Upvote 0
I need the other stuff because I have other fields that I need to display in the query.
 
Upvote 0
I need the other stuff because I have other fields that I need to display in the query.
OK, you are confusing a bunch of different things here. It is important to get them straight.

Update Queries are used to update values in a table. They are NOT used for display purposes (for showing people data or for providing Forms, Reports, or Exports with data). This is true of all ACTION Queries (Update, Append, Delete). They are used for ACTIONS only, not for displaying data.

Select Queries are used to display data or supply Forms, Reports, or Exports with data. You CANNOT permanently change the value of a table field in a Select query through a formula (though if you have an updateable query, you can allow users to manually update field values in them).

Select Queries can show Calculated Fields. These are simply calculations and are NOT mapped to or stored in any underlying table field. They are dynamic, on-the-fly calculations.
A general rule of thumb with Access is that anything which can easily be calculated on-the-fly should NOT be stored in an underlying table field. Never store that which can easily be calculated! If they can easily be calculated, there is no reason to store them. Select Queries can be used as the data source of other Queries, Forms, Reports, and Exports, so there is no reason to store everything at the Table level.

Does that clarify things for you?
 
Upvote 0
Yes, that does clarify things for me. Thank you for your help. I really appreciate it
 
Upvote 0
Great!
You are welcome.
 
Upvote 0

Forum statistics

Threads
1,221,771
Messages
6,161,847
Members
451,723
Latest member
Rachetsely

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top