SQL = "Select * From TAB WHERE AGG=#15/09/2010#"
Instead the fixed date is possible to filterd the max date into the filed AGG and store the value of max date in a variable?
MAX DATE IN QUERY
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: MAX DATE IN QUERY
You could use
SQL = SELECT Max(AGG) As MaxAGG FROM TAB"
Open a recordset on this SQL string, let's say you name it RS. Then use
MyVar = RS!MaxAGG
to store the value in a variable.
SQL = SELECT Max(AGG) As MaxAGG FROM TAB"
Open a recordset on this SQL string, let's say you name it RS. Then use
MyVar = RS!MaxAGG
to store the value in a variable.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4373
- Joined: 26 Apr 2010, 17:36
Re: MAX DATE IN QUERY
But your query select also all records whit the filter MaxAGG?HansV wrote:You could use
SQL = SELECT Max(AGG) As MaxAGG FROM TAB"
Open a recordset on this SQL string, let's say you name it RS. Then use
MyVar = RS!MaxAGG
to store the value in a variable.
i have used * param in my old query...
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: MAX DATE IN QUERY
Sorry, I don't understand. Do you want to select the entire record or do you want to get the maximum value of AGG?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4373
- Joined: 26 Apr 2010, 17:36
Re: MAX DATE IN QUERY
I need to extract all records from tab where the max date are preesnt in AGGHansV wrote:Sorry, I don't understand. Do you want to select the entire record or do you want to get the maximum value of AGG?
-
- Administrator
- Posts: 78631
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: MAX DATE IN QUERY
OK, try this then:
SQL = "SELECT * FROM TAB WHERE AGG=(SELECT Max(AGG) FROM TAB)"
SQL = "SELECT * FROM TAB WHERE AGG=(SELECT Max(AGG) FROM TAB)"
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4373
- Joined: 26 Apr 2010, 17:36
Re: MAX DATE IN QUERY
I lo** you!HansV wrote:OK, try this then:
SQL = "SELECT * FROM TAB WHERE AGG=(SELECT Max(AGG) FROM TAB)"