By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,064 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

Open Report by looking for the Report name on a table

P: n/a
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:

Dim stDocName As String
Dim mth As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")

'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If

Oct 20 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Orchid wrote:
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:
If IsNull(Me.CurrentMonth) then
'no need to process if current month is empty.
Dim stDocName As String
Dim mth As Date
'Dim mth As Date unneeded
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")
'mth = Format(Me.CurrentMonth, "m/dd/yyyy") unneeded

If mth < 10 then
strDocName = "Report1"
Else
strDocName = "Report2"
Endif

DoCmd.OpenReport strDocName, acPreview

'the rest of your code is unneeded near as I can make out
>
'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If
Oct 20 '06 #2

P: n/a
The error comes from your statement
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

It should be
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
'RSD4' and month = " & mth

Hope that helps!

Orchid wrote:
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:

Dim stDocName As String
Dim mth As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")

'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If
Oct 20 '06 #3

P: n/a
Thanks for your reply!
I want the report name to be retrieved from a table instead of hard
coded, because I will have another version for the report which is more
than 2 version reports opened by the same button. Therefore, to make
it easier, I have a table to record which report name to open for the
month. I want to match the month from the table then open the report
name from table.
Do you have other suggestions? Thanks in advance!

salad wrote:
Orchid wrote:
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:

If IsNull(Me.CurrentMonth) then
'no need to process if current month is empty.
Dim stDocName As String
Dim mth As Date

'Dim mth As Date unneeded
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")

'mth = Format(Me.CurrentMonth, "m/dd/yyyy") unneeded

If mth < 10 then
strDocName = "Report1"
Else
strDocName = "Report2"
Endif

DoCmd.OpenReport strDocName, acPreview

'the rest of your code is unneeded near as I can make out

'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If
Oct 20 '06 #4

P: n/a
thanks Jeff, select statement wrote correctly now, but I still have
error: "The report name 'SELECT ReportToOpen FROM ReportOpenTable WHERE
ReportID = 'RSD4' and month= 9/30/2006' you entered in either the
property sheet or macro is misspelled or refers to a report that
doesn't exist."

How can I pass the report name from strSQL to stDocName? Thanks for
your help!!
Jeff L wrote:
The error comes from your statement
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

It should be
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
'RSD4' and month = " & mth

Hope that helps!

Orchid wrote:
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:

Dim stDocName As String
Dim mth As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")

'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If
Oct 20 '06 #5

P: n/a
Orchid wrote:
thanks Jeff, select statement wrote correctly now, but I still have
error: "The report name 'SELECT ReportToOpen FROM ReportOpenTable WHERE
ReportID = 'RSD4' and month= 9/30/2006' you entered in either the
property sheet or macro is misspelled or refers to a report that
doesn't exist."

How can I pass the report name from strSQL to stDocName? Thanks for
your help!!
Do you have a field called Month in the table?

If so, is each month specified?

If your field Month is a integer in the table, you can use Between.
Month Between 1 And 10

If you are using dates; 10/15/2006, then you need to surround with #
Date Between #1/1/2006# And #10/31/2006#
>

Jeff L wrote:
>>The error comes from your statement
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

It should be
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
'RSD4' and month = " & mth

Hope that helps!

Orchid wrote:
>>>Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:

Dim stDocName As String
Dim mth As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")

'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If

Oct 20 '06 #6

P: n/a
salad wrote:
If you are using dates; 10/15/2006, then you need to surround with #
Date Between #1/1/2006# And #10/31/2006#
I don't know how you are storing date values; as string? as date? If
you are mixing and matching formats you should convert one to the other.
See Cdate or Cstr.

You are, most likely, making this a bigger deal than what you need it to be.

You really should look at date functions; Month, Year, DateAdd,
DateDiff, CDate, etc. You should also remember dates are surrounded by
#, strings by quotes, and numerics aren't surrounded by quotes or #'s.
Oct 20 '06 #7

P: n/a
Thanks Salad, yes, I have a field "Month" with Date dataType on my
table. The date "9/30/2006" is the Me!currentMonth on a form. The
error seems it couldn't retrieve the report name from the table. Any
idea on how to pass the recordset to a string? Thanks!

salad wrote:
salad wrote:
If you are using dates; 10/15/2006, then you need to surround with #
Date Between #1/1/2006# And #10/31/2006#

I don't know how you are storing date values; as string? as date? If
you are mixing and matching formats you should convert one to the other.
See Cdate or Cstr.

You are, most likely, making this a bigger deal than what you need it to be.

You really should look at date functions; Month, Year, DateAdd,
DateDiff, CDate, etc. You should also remember dates are surrounded by
#, strings by quotes, and numerics aren't surrounded by quotes or #'s.
Oct 20 '06 #8

P: n/a
OK, I think I see what you are doing. You are using strSQL to get the
report to open from your table. You do that by Set rs =
db.OpenRecordset(strSQL)
Now, insted of stDocName = strSQL you want
stDocName = rs.ReportToOpen


Jeff L wrote:
The error comes from your statement
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

It should be
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
'RSD4' and month = " & mth

Hope that helps!

Orchid wrote:
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:

Dim stDocName As String
Dim mth As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")

'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If
Oct 20 '06 #9

P: n/a
Jeff, Thanks alot! it works fine with the change.
Now I got another problem that when I have strSQL = "SELECT
ReportToOpen FROM ReportOpenTable WHERE ReportID = 'RSD4' and month = "
& Me.CurrentMonth, It said "no current record". If I hard code it
month = #9/30/2006#, then it works fine. It seems couldn't read the
date. Any idea? again, thanks for your help.

Jeff L wrote:
OK, I think I see what you are doing. You are using strSQL to get the
report to open from your table. You do that by Set rs =
db.OpenRecordset(strSQL)
Now, insted of stDocName = strSQL you want
stDocName = rs.ReportToOpen


Jeff L wrote:
The error comes from your statement
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

It should be
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
'RSD4' and month = " & mth

Hope that helps!

Orchid wrote:
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.
>
I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.
>
Could someone help me on this? Your help is greatly appreciated!!
>
Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:
>
Dim stDocName As String
Dim mth As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
>
>
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")
>
'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"
>
Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"
>
'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then
>
DoCmd.OpenReport stDocName, acPreview
>
'**Else
'**MsgBox ("oop")
>
'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If
Oct 20 '06 #10

P: n/a
Orchid wrote:
Jeff, Thanks alot! it works fine with the change.
Now I got another problem that when I have strSQL = "SELECT
ReportToOpen FROM ReportOpenTable WHERE ReportID = 'RSD4' and month = "
& Me.CurrentMonth, It said "no current record". If I hard code it
month = #9/30/2006#, then it works fine. It seems couldn't read the
date. Any idea? again, thanks for your help.
WHERE ReportID = 'RSD4' and month = #" & Me.CurrentMonth & "#"
>
Jeff L wrote:
>>OK, I think I see what you are doing. You are using strSQL to get the
report to open from your table. You do that by Set rs =
db.OpenRecordset(strSQL)
Now, insted of stDocName = strSQL you want
stDocName = rs.ReportToOpen


Jeff L wrote:
>>>The error comes from your statement
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

It should be
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
'RSD4' and month = " & mth

Hope that helps!

Orchid wrote:

Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October, so I created report
version 2. I want a same Command Button to open the appropriated
version report for the specific month.

I create a table with the following Fields: Month, ReportID,
ReportToOpen (this is the exact report name). On a form, I have input
field "Month", and a Command Button to click & open the report. I
create VB code to look for the Report name from the table and open the
specific report when click the button after input a month on the form.
I need a right report to open.

Could someone help me on this? Your help is greatly appreciated!!

Here is my code, but with error ("Too few parameters. Expected 2.). I
am not sure if this is the right way to do it, but this's the logic i
have:

Dim stDocName As String
Dim mth As Date
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb()
mth = Format(Me.CurrentMonth, "m/dd/yyyy")

'**stDocName = Tables![ReportOpenTable]![ReportToOpen]
strSQL = "SELECT ReportToOpen FROM ReportOpenTable WHERE ReportID =
RSD4 and month= mth"

Set rs = db.OpenRecordset(strSQL)
stDocName = strSQL
'**stDocName = "RSD3-Sales by Territory=TotalV2"

'**If DLookup("[Position]", "ReportOpenTable", "[ReportID] = 'RSD4'")
= "RSD" '**Then

DoCmd.OpenReport stDocName, acPreview

'**Else
'**MsgBox ("oop")

'**DoCmd.OpenReport "RSD3-Sales by Territory=Total", acPreview
'**End If

M
Oct 20 '06 #11

P: n/a
"Orchid" <yh******@yahoo.comwrote in
news:11*********************@m7g2000cwm.googlegrou ps.com:
Dim mth As Date

mth = Format(Me.CurrentMonth, "m/dd/yyyy")
If the Month field in the table is a date field, this is correct. If
it's a number field, it's not, and you should change the data type
of the variable mth to Integer.

If it's a date, then October will be represented as 10/1/[year].

And if your form field CurrentMonth has "10" in it, then the value
of mth will be 1/9/1900, because you're passing the integer 10 to
it, which gives you the 10th day from September 30th, 1900.

If the Month field is a date, then you need to convert whatever is
in your form field to the first of the month of the current year.
You can do that just by concatenating:

Me.CurrentMonth & "\1\" & Year(Date())

That will give you a string value that you can use as a criterion in
your SQL (with the date delimiter #, i.e., Month=#10/1/2006#).

I would suggest that your best method for this is to have the month
field be an integer and then you should be able to use the
CurrentMonth field without manipulation, as well as needing no
delimiters in the WHERE clause.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Oct 20 '06 #12

P: n/a
"Orchid" <yh******@yahoo.comwrote in
news:11*********************@m7g2000cwm.googlegrou ps.com:
Now I got another problem that when I have strSQL = "SELECT
ReportToOpen FROM ReportOpenTable WHERE ReportID = 'RSD4' and
month = " & Me.CurrentMonth, It said "no current record". If I
hard code it month = #9/30/2006#, then it works fine. It seems
couldn't read the date. Any idea? again, thanks for your help.
You're passing it a date in 1900 because your this line of your
code:

mth = Format(Me.CurrentMonth, "m/dd/yyyy")

is going to return something based on the value passed in. If
Me!CurrentMonth is an integer value from 1-12, then you're going to
get dates at the beginning of 1900, because you're passing an
integer value to the Format() functions. Try Format(10, "m/d/yyyy")
in the immediate window and you'll see.

On the other hand, if you have a full date value in your
CurrentMonth field, then it's going to have to match the date value
in your Month field in the table exactly.

If you have the display of your Month field set to "m/yyyy", for
instance, keep in mind that an entry that displays as 10/2006 is
actually stored as 10/1/2006. So, if you're current month field is
9/30/2006, it's not going to match a record that says 10/1/2006.

I wouldn't use a date field for storing Month in your report table
-- I'd just use an integer.

Of course, if there's a hard date after which you want to switch
report formats, then I'd encode a date and *not* call it month,
because it's more a "date effective" field. In that case, I'd just
use the CurrentMonth date value and look for the value that is TOP 1
(descending sorted) that is Greater than the CurrentMonth date. The
reason for the TOP 1 is because if you're storing it in a table,
you're expecting there to be more than 2 report formats (otherwise,
you could just use a hard cut-off date in code, with no need to
store report names), and that means that you need the lowest value
from the table for the reporting period.

For example, if you have a report that is effective until 9/2006,
another that's effective starting 10/2006, and a report that's
effect 3/2007, for printing 11/2006, you want the middle of the two.
That means you want the first one greater than the month you're
printing, but you don't want the 3/2007 one. That's why you'd use a
TOP 1. Another alternative would be to use an ASCENDING sorted
recordset and just use the value from the first row. That's probably
easier, or course, but I'd use the TOP 1 because it's more correct,
as it returns only the correct row.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Oct 20 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.