Query Replace Function

bs0d

Well-known Member
Joined
Dec 29, 2006
Messages
622
I'm building a query in MS Access.

I have a time series of data (table 'A'), and comments with dates in a separate table (table 'B'). I have built a query to show data for an item, and the comments from Table B on the appropriate date where a matching item ID is found.

Is it possible for me to put in the max value of a given field from table 'A' at each point where a comment is currently shown from table B in the query?

I was thinking you could use replace(), but it's getting an error. I tried:

Code:
Expr1: Replace([table_b].[comment], "*", Max([table_a].[field]))
 
Ok so a quick fix was changing the IIF condition to id_table_a = id_table_b

I tested this at first in Access, but wasn't getting the desired results. It turns out, I was using the wrong ID to test. Thanks again
 
Last edited:
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
The SQL code of your query should look something like this:
Code:
SELECT 
    Table_A.Date, 
    Table_A.Value, 
    IIf([Table_B].[Comment] Is Not Null,DMax("Value","Table_A"),"") AS Comment
FROM 
    Table_A 
LEFT JOIN 
    Table_B 
ON 
    Table_A.Date = Table_B.Date;
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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