Sequential Numbering Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've tried unsuccessfully, using DCount and a subquery to number records in
my query.

In a query called "ModelCount", I'm trying to number the records returned
from the "Model Build Count" query using the resourceID field, which is a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID <=" &
[resourceID]) and other ways of writing this, but I keep getting error
messages. Any help is appreciated. Thanks.
 
Since your query or table name has spaces, you have to use [] around the
name.
If ResourceID is a Text field then you need to surround it with quote marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" & [resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" & [resourceID] &
"'")
 
Thanks John. This should be so easy and I getting so frustrated. I tried
your suggestions and I either get #error in every field result or I got the
following error msg when running the query, "the expression you entered as a
query parameter produced this error, "the object doesn't contain the
automation object "begin date", which is my parameter. I've tried adding the
parameters (begin date & end date) in the query and still get the same
message.

Maybe I'm not understanding what DCount does. I just want a column that
numbers the records sequentially. I would assume then, that it doesn't
matter which field I name in the DCount function, as long as it's not null?
Thanks again

John Spencer said:
Since your query or table name has spaces, you have to use [] around the
name.
If ResourceID is a Text field then you need to surround it with quote marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" & [resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" & [resourceID] &
"'")

Alex said:
I've tried unsuccessfully, using DCount and a subquery to number records
in
my query.

In a query called "ModelCount", I'm trying to number the records returned
from the "Model Build Count" query using the resourceID field, which is a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID <=" &
[resourceID]) and other ways of writing this, but I keep getting error
messages. Any help is appreciated. Thanks.
 
Post the SQL of the query you are trying to run. You may also need to post
the Model Build Count, if that is a query.

Troubleshooting.
Just try
DCount("*","[Model Build Count]")

If that errors, then the error has something to do with [Model Build Count].


Alex said:
Thanks John. This should be so easy and I getting so frustrated. I tried
your suggestions and I either get #error in every field result or I got
the
following error msg when running the query, "the expression you entered as
a
query parameter produced this error, "the object doesn't contain the
automation object "begin date", which is my parameter. I've tried adding
the
parameters (begin date & end date) in the query and still get the same
message.

Maybe I'm not understanding what DCount does. I just want a column that
numbers the records sequentially. I would assume then, that it doesn't
matter which field I name in the DCount function, as long as it's not
null?
Thanks again

John Spencer said:
Since your query or table name has spaces, you have to use [] around the
name.
If ResourceID is a Text field then you need to surround it with quote
marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" &
[resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" & [resourceID]
&
"'")

Alex said:
I've tried unsuccessfully, using DCount and a subquery to number
records
in
my query.

In a query called "ModelCount", I'm trying to number the records
returned
from the "Model Build Count" query using the resourceID field, which is
a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID <=" &
[resourceID]) and other ways of writing this, but I keep getting error
messages. Any help is appreciated. Thanks.
 
Below is my code: I'm finally getting a number, but it's the same number
that is in the AAD field, which is an autonumber field. What I want is that
if 1/1/06 - 3/31/06 results in 189 records, then I want the Test column to
number the records 1 - 189. AAD is key field, but do I have to use a key
field? Thanks

SELECT AURORA_ACCOUNTING_DAYS.AAD, AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY, DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD
<=" & [AAD]) AS Test
FROM AURORA_ACCOUNTING_DAYS
WHERE (((AURORA_ACCOUNTING_DAYS.ODATE) Between [begin date] And [end date]));

John Spencer said:
Post the SQL of the query you are trying to run. You may also need to post
the Model Build Count, if that is a query.

Troubleshooting.
Just try
DCount("*","[Model Build Count]")

If that errors, then the error has something to do with [Model Build Count].


Alex said:
Thanks John. This should be so easy and I getting so frustrated. I tried
your suggestions and I either get #error in every field result or I got
the
following error msg when running the query, "the expression you entered as
a
query parameter produced this error, "the object doesn't contain the
automation object "begin date", which is my parameter. I've tried adding
the
parameters (begin date & end date) in the query and still get the same
message.

Maybe I'm not understanding what DCount does. I just want a column that
numbers the records sequentially. I would assume then, that it doesn't
matter which field I name in the DCount function, as long as it's not
null?
Thanks again

John Spencer said:
Since your query or table name has spaces, you have to use [] around the
name.
If ResourceID is a Text field then you need to surround it with quote
marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" &
[resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" & [resourceID]
&
"'")

I've tried unsuccessfully, using DCount and a subquery to number
records
in
my query.

In a query called "ModelCount", I'm trying to number the records
returned
from the "Model Build Count" query using the resourceID field, which is
a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID <=" &
[resourceID]) and other ways of writing this, but I keep getting error
messages. Any help is appreciated. Thanks.
 
You do need to incorporate the date range in your DCount function. I think that
the following will return what you want.

DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD <=" & [AAD] & " AND ODATE Between
#" & [begin date] & "# And #" & [end date] &"#") as Rank

You can probably do the same thing using a subquery

SELECT AURORA_ACCOUNTING_DAYS.AAD,
AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
(SELECT Count(AAD)
FROM AURORA_ACCOUNTING_DAYS] as A
WHERE A.AAD <= AURORA_ACCOUNTING_DAYS.AAD
AND A.ODATE Between [begin date] And [end date]) as Rank
FROM AURORA_ACCOUNTING_DAYS
WHERE AURORA_ACCOUNTING_DAYS.ODATE Between [begin date] And [end date]
Below is my code: I'm finally getting a number, but it's the same number
that is in the AAD field, which is an autonumber field. What I want is that
if 1/1/06 - 3/31/06 results in 189 records, then I want the Test column to
number the records 1 - 189. AAD is key field, but do I have to use a key
field? Thanks

SELECT AURORA_ACCOUNTING_DAYS.AAD, AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY, DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD
<=" & [AAD]) AS Test
FROM AURORA_ACCOUNTING_DAYS
WHERE (((AURORA_ACCOUNTING_DAYS.ODATE) Between [begin date] And [end date]));

John Spencer said:
Post the SQL of the query you are trying to run. You may also need to post
the Model Build Count, if that is a query.

Troubleshooting.
Just try
DCount("*","[Model Build Count]")

If that errors, then the error has something to do with [Model Build Count].


Alex said:
Thanks John. This should be so easy and I getting so frustrated. I tried
your suggestions and I either get #error in every field result or I got
the
following error msg when running the query, "the expression you entered as
a
query parameter produced this error, "the object doesn't contain the
automation object "begin date", which is my parameter. I've tried adding
the
parameters (begin date & end date) in the query and still get the same
message.

Maybe I'm not understanding what DCount does. I just want a column that
numbers the records sequentially. I would assume then, that it doesn't
matter which field I name in the DCount function, as long as it's not
null?
Thanks again

:

Since your query or table name has spaces, you have to use [] around the
name.
If ResourceID is a Text field then you need to surround it with quote
marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" &
[resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" & [resourceID]
&
"'")

I've tried unsuccessfully, using DCount and a subquery to number
records
in
my query.

In a query called "ModelCount", I'm trying to number the records
returned
from the "Model Build Count" query using the resourceID field, which is
a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID <=" &
[resourceID]) and other ways of writing this, but I keep getting error
messages. Any help is appreciated. Thanks.
 
Thanks John, that finally worked. Now, however I need to do the same thing
but instead of the between/and parameter in the ODATE field, I need the
parameters to be in two separate fields, Field1 [beginning of horizon] and
Field2 [ending of horizon]. I've tried re-writing what you gave me below to
no avail - grrrrr. Can you help? Thanks much.


This is what I've tried:

SELECT [Model Count By Build Date - Q00].[Accounting Date], [Model Count By
Build Date - Q00].resourceID, [Model Count By Build Date -
Q00].Start_Horizon, [Model Count By Build Date - Q00].End_Horizon,
DCount("resourceID","[Model Count By Build Date - Q00]","resourceID<=""" &
[resourceID] & """ And Start_Horizon = #" & [Beginning Of Horizon] & "# And
End_Horizon = #" & [Ending Of Horizon] & "#") AS NumberRecords
FROM [Model Count By Build Date - Q00];


Alex

John Spencer said:
You do need to incorporate the date range in your DCount function. I think that
the following will return what you want.

DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD <=" & [AAD] & " AND ODATE Between
#" & [begin date] & "# And #" & [end date] &"#") as Rank

You can probably do the same thing using a subquery

SELECT AURORA_ACCOUNTING_DAYS.AAD,
AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
(SELECT Count(AAD)
FROM AURORA_ACCOUNTING_DAYS] as A
WHERE A.AAD <= AURORA_ACCOUNTING_DAYS.AAD
AND A.ODATE Between [begin date] And [end date]) as Rank
FROM AURORA_ACCOUNTING_DAYS
WHERE AURORA_ACCOUNTING_DAYS.ODATE Between [begin date] And [end date]
Below is my code: I'm finally getting a number, but it's the same number
that is in the AAD field, which is an autonumber field. What I want is that
if 1/1/06 - 3/31/06 results in 189 records, then I want the Test column to
number the records 1 - 189. AAD is key field, but do I have to use a key
field? Thanks

SELECT AURORA_ACCOUNTING_DAYS.AAD, AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY, DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD
<=" & [AAD]) AS Test
FROM AURORA_ACCOUNTING_DAYS
WHERE (((AURORA_ACCOUNTING_DAYS.ODATE) Between [begin date] And [end date]));

John Spencer said:
Post the SQL of the query you are trying to run. You may also need to post
the Model Build Count, if that is a query.

Troubleshooting.
Just try
DCount("*","[Model Build Count]")

If that errors, then the error has something to do with [Model Build Count].


Thanks John. This should be so easy and I getting so frustrated. I tried
your suggestions and I either get #error in every field result or I got
the
following error msg when running the query, "the expression you entered as
a
query parameter produced this error, "the object doesn't contain the
automation object "begin date", which is my parameter. I've tried adding
the
parameters (begin date & end date) in the query and still get the same
message.

Maybe I'm not understanding what DCount does. I just want a column that
numbers the records sequentially. I would assume then, that it doesn't
matter which field I name in the DCount function, as long as it's not
null?
Thanks again

:

Since your query or table name has spaces, you have to use [] around the
name.
If ResourceID is a Text field then you need to surround it with quote
marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" &
[resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" & [resourceID]
&
"'")

I've tried unsuccessfully, using DCount and a subquery to number
records
in
my query.

In a query called "ModelCount", I'm trying to number the records
returned
from the "Model Build Count" query using the resourceID field, which is
a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID <=" &
[resourceID]) and other ways of writing this, but I keep getting error
messages. Any help is appreciated. Thanks.
 
What types of fields are Beginning of Horizon and Ending of Horizon? Are
they dates? or Numbers? or Text?

If numbers (number type field) then remove the # delimiters - that is used
for dates
If text, try changing the # to two quote marks- which is one method of
specifying text/string data.

Assuming text fields and that the text fields apostrophes then this may work

SELECT [Model Count By Build Date - Q00].[Accounting Date],
[Model Count By Build Date - Q00].resourceID,
[Model Count By Build Date - Q00].Start_Horizon,
[Model Count By Build Date - Q00].End_Horizon,
DCount("resourceID","[Model Count By Build Date - Q00]",
"resourceID<=""" & [resourceID] & """ And Start_Horizon = """ & [Beginning
Of Horizon] &
""" And End_Horizon = """ & [Ending Of Horizon] & """ ") AS NumberRecords
FROM [Model Count By Build Date - Q00];

Alex said:
Thanks John, that finally worked. Now, however I need to do the same
thing
but instead of the between/and parameter in the ODATE field, I need the
parameters to be in two separate fields, Field1 [beginning of horizon] and
Field2 [ending of horizon]. I've tried re-writing what you gave me below
to
no avail - grrrrr. Can you help? Thanks much.


This is what I've tried:

SELECT [Model Count By Build Date - Q00].[Accounting Date], [Model Count
By
Build Date - Q00].resourceID, [Model Count By Build Date -
Q00].Start_Horizon, [Model Count By Build Date - Q00].End_Horizon,
DCount("resourceID","[Model Count By Build Date - Q00]","resourceID<=""" &
[resourceID] & """ And Start_Horizon = #" & [Beginning Of Horizon] & "#
And
End_Horizon = #" & [Ending Of Horizon] & "#") AS NumberRecords
FROM [Model Count By Build Date - Q00];


Alex

John Spencer said:
You do need to incorporate the date range in your DCount function. I
think that
the following will return what you want.

DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD <=" & [AAD] & " AND ODATE
Between
#" & [begin date] & "# And #" & [end date] &"#") as Rank

You can probably do the same thing using a subquery

SELECT AURORA_ACCOUNTING_DAYS.AAD,
AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
(SELECT Count(AAD)
FROM AURORA_ACCOUNTING_DAYS] as A
WHERE A.AAD <= AURORA_ACCOUNTING_DAYS.AAD
AND A.ODATE Between [begin date] And [end date]) as Rank
FROM AURORA_ACCOUNTING_DAYS
WHERE AURORA_ACCOUNTING_DAYS.ODATE Between [begin date] And [end date]
Below is my code: I'm finally getting a number, but it's the same
number
that is in the AAD field, which is an autonumber field. What I want is
that
if 1/1/06 - 3/31/06 results in 189 records, then I want the Test column
to
number the records 1 - 189. AAD is key field, but do I have to use a
key
field? Thanks

SELECT AURORA_ACCOUNTING_DAYS.AAD, AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD
<=" & [AAD]) AS Test
FROM AURORA_ACCOUNTING_DAYS
WHERE (((AURORA_ACCOUNTING_DAYS.ODATE) Between [begin date] And [end
date]));

:

Post the SQL of the query you are trying to run. You may also need
to post
the Model Build Count, if that is a query.

Troubleshooting.
Just try
DCount("*","[Model Build Count]")

If that errors, then the error has something to do with [Model Build
Count].


Thanks John. This should be so easy and I getting so frustrated.
I tried
your suggestions and I either get #error in every field result or I
got
the
following error msg when running the query, "the expression you
entered as
a
query parameter produced this error, "the object doesn't contain
the
automation object "begin date", which is my parameter. I've tried
adding
the
parameters (begin date & end date) in the query and still get the
same
message.

Maybe I'm not understanding what DCount does. I just want a column
that
numbers the records sequentially. I would assume then, that it
doesn't
matter which field I name in the DCount function, as long as it's
not
null?
Thanks again

:

Since your query or table name has spaces, you have to use []
around the
name.
If ResourceID is a Text field then you need to surround it with
quote
marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" &
[resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" &
[resourceID]
&
"'")

I've tried unsuccessfully, using DCount and a subquery to number
records
in
my query.

In a query called "ModelCount", I'm trying to number the records
returned
from the "Model Build Count" query using the resourceID field,
which is
a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID
<=" &
[resourceID]) and other ways of writing this, but I keep getting
error
messages. Any help is appreciated. Thanks.
 
They are dates. I'm trying hard here and still failing. This is one of my
many tries. Thanks for your persistance.

DCount("resourceID","[Model Count By Build Date - Q00]","resourceID<=""" &
[resourceID] & """ And Start_Horizon = #" & [Beginning Of Horizon] & "# And
End_Horizon = #" & [Ending Of Horizon] & "#") AS NumberRecords

John Spencer said:
What types of fields are Beginning of Horizon and Ending of Horizon? Are
they dates? or Numbers? or Text?

If numbers (number type field) then remove the # delimiters - that is used
for dates
If text, try changing the # to two quote marks- which is one method of
specifying text/string data.

Assuming text fields and that the text fields apostrophes then this may work

SELECT [Model Count By Build Date - Q00].[Accounting Date],
[Model Count By Build Date - Q00].resourceID,
[Model Count By Build Date - Q00].Start_Horizon,
[Model Count By Build Date - Q00].End_Horizon,
DCount("resourceID","[Model Count By Build Date - Q00]",
"resourceID<=""" & [resourceID] & """ And Start_Horizon = """ & [Beginning
Of Horizon] &
""" And End_Horizon = """ & [Ending Of Horizon] & """ ") AS NumberRecords
FROM [Model Count By Build Date - Q00];

Alex said:
Thanks John, that finally worked. Now, however I need to do the same
thing
but instead of the between/and parameter in the ODATE field, I need the
parameters to be in two separate fields, Field1 [beginning of horizon] and
Field2 [ending of horizon]. I've tried re-writing what you gave me below
to
no avail - grrrrr. Can you help? Thanks much.


This is what I've tried:

SELECT [Model Count By Build Date - Q00].[Accounting Date], [Model Count
By
Build Date - Q00].resourceID, [Model Count By Build Date -
Q00].Start_Horizon, [Model Count By Build Date - Q00].End_Horizon,
DCount("resourceID","[Model Count By Build Date - Q00]","resourceID<=""" &
[resourceID] & """ And Start_Horizon = #" & [Beginning Of Horizon] & "#
And
End_Horizon = #" & [Ending Of Horizon] & "#") AS NumberRecords
FROM [Model Count By Build Date - Q00];


Alex

John Spencer said:
You do need to incorporate the date range in your DCount function. I
think that
the following will return what you want.

DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD <=" & [AAD] & " AND ODATE
Between
#" & [begin date] & "# And #" & [end date] &"#") as Rank

You can probably do the same thing using a subquery

SELECT AURORA_ACCOUNTING_DAYS.AAD,
AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
(SELECT Count(AAD)
FROM AURORA_ACCOUNTING_DAYS] as A
WHERE A.AAD <= AURORA_ACCOUNTING_DAYS.AAD
AND A.ODATE Between [begin date] And [end date]) as Rank
FROM AURORA_ACCOUNTING_DAYS
WHERE AURORA_ACCOUNTING_DAYS.ODATE Between [begin date] And [end date]

Alex wrote:

Below is my code: I'm finally getting a number, but it's the same
number
that is in the AAD field, which is an autonumber field. What I want is
that
if 1/1/06 - 3/31/06 results in 189 records, then I want the Test column
to
number the records 1 - 189. AAD is key field, but do I have to use a
key
field? Thanks

SELECT AURORA_ACCOUNTING_DAYS.AAD, AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD
<=" & [AAD]) AS Test
FROM AURORA_ACCOUNTING_DAYS
WHERE (((AURORA_ACCOUNTING_DAYS.ODATE) Between [begin date] And [end
date]));

:

Post the SQL of the query you are trying to run. You may also need
to post
the Model Build Count, if that is a query.

Troubleshooting.
Just try
DCount("*","[Model Build Count]")

If that errors, then the error has something to do with [Model Build
Count].


Thanks John. This should be so easy and I getting so frustrated.
I tried
your suggestions and I either get #error in every field result or I
got
the
following error msg when running the query, "the expression you
entered as
a
query parameter produced this error, "the object doesn't contain
the
automation object "begin date", which is my parameter. I've tried
adding
the
parameters (begin date & end date) in the query and still get the
same
message.

Maybe I'm not understanding what DCount does. I just want a column
that
numbers the records sequentially. I would assume then, that it
doesn't
matter which field I name in the DCount function, as long as it's
not
null?
Thanks again

:

Since your query or table name has spaces, you have to use []
around the
name.
If ResourceID is a Text field then you need to surround it with
quote
marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" &
[resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" &
[resourceID]
&
"'")

I've tried unsuccessfully, using DCount and a subquery to number
records
in
my query.

In a query called "ModelCount", I'm trying to number the records
returned
from the "Model Build Count" query using the resourceID field,
which is
a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID
<=" &
[resourceID]) and other ways of writing this, but I keep getting
error
messages. Any help is appreciated. Thanks.
 
Any error messages? Or are you just getting wrong results?

One thing I see is that you don't have a space between resourceID and <=


DCount("resourceID","[Model Count By Build Date - Q00]","resourceID <=""" &
[resourceID] & """ And Start_Horizon = #" & [Beginning Of Horizon] & "# And
End_Horizon = #" & [Ending Of Horizon] & "#") AS NumberRecords

You can try Format([Ending of Horizon],"#yyyy/mmd/dd hh:nn:ss#") just to ensure
the dates are correctly interpreted.


DCount("resourceID","[Model Count By Build Date - Q00]","resourceID <=""" &
[resourceID] & """ And Start_Horizon = " & Format([Beginning of
Horizon],"#yyyy/mmd/dd hh:nn:ss#") & " And
End_Horizon = " & Format([Ending of Horizon],"#yyyy/mmd/dd hh:nn:ss#")) AS NumberRecords


They are dates. I'm trying hard here and still failing. This is one of my
many tries. Thanks for your persistance.

DCount("resourceID","[Model Count By Build Date - Q00]","resourceID<=""" &
[resourceID] & """ And Start_Horizon = #" & [Beginning Of Horizon] & "# And
End_Horizon = #" & [Ending Of Horizon] & "#") AS NumberRecords

John Spencer said:
What types of fields are Beginning of Horizon and Ending of Horizon? Are
they dates? or Numbers? or Text?

If numbers (number type field) then remove the # delimiters - that is used
for dates
If text, try changing the # to two quote marks- which is one method of
specifying text/string data.

Assuming text fields and that the text fields apostrophes then this may work

SELECT [Model Count By Build Date - Q00].[Accounting Date],
[Model Count By Build Date - Q00].resourceID,
[Model Count By Build Date - Q00].Start_Horizon,
[Model Count By Build Date - Q00].End_Horizon,
DCount("resourceID","[Model Count By Build Date - Q00]",
"resourceID<=""" & [resourceID] & """ And Start_Horizon = """ & [Beginning
Of Horizon] &
""" And End_Horizon = """ & [Ending Of Horizon] & """ ") AS NumberRecords
FROM [Model Count By Build Date - Q00];

Alex said:
Thanks John, that finally worked. Now, however I need to do the same
thing
but instead of the between/and parameter in the ODATE field, I need the
parameters to be in two separate fields, Field1 [beginning of horizon] and
Field2 [ending of horizon]. I've tried re-writing what you gave me below
to
no avail - grrrrr. Can you help? Thanks much.


This is what I've tried:

SELECT [Model Count By Build Date - Q00].[Accounting Date], [Model Count
By
Build Date - Q00].resourceID, [Model Count By Build Date -
Q00].Start_Horizon, [Model Count By Build Date - Q00].End_Horizon,
DCount("resourceID","[Model Count By Build Date - Q00]","resourceID<=""" &
[resourceID] & """ And Start_Horizon = #" & [Beginning Of Horizon] & "#
And
End_Horizon = #" & [Ending Of Horizon] & "#") AS NumberRecords
FROM [Model Count By Build Date - Q00];


Alex

:

You do need to incorporate the date range in your DCount function. I
think that
the following will return what you want.

DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD <=" & [AAD] & " AND ODATE
Between
#" & [begin date] & "# And #" & [end date] &"#") as Rank

You can probably do the same thing using a subquery

SELECT AURORA_ACCOUNTING_DAYS.AAD,
AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
(SELECT Count(AAD)
FROM AURORA_ACCOUNTING_DAYS] as A
WHERE A.AAD <= AURORA_ACCOUNTING_DAYS.AAD
AND A.ODATE Between [begin date] And [end date]) as Rank
FROM AURORA_ACCOUNTING_DAYS
WHERE AURORA_ACCOUNTING_DAYS.ODATE Between [begin date] And [end date]

Alex wrote:

Below is my code: I'm finally getting a number, but it's the same
number
that is in the AAD field, which is an autonumber field. What I want is
that
if 1/1/06 - 3/31/06 results in 189 records, then I want the Test column
to
number the records 1 - 189. AAD is key field, but do I have to use a
key
field? Thanks

SELECT AURORA_ACCOUNTING_DAYS.AAD, AURORA_ACCOUNTING_DAYS.ODATE,
AURORA_ACCOUNTING_DAYS.WORKDAY,
DCount("AAD","[AURORA_ACCOUNTING_DAYS]","AAD
<=" & [AAD]) AS Test
FROM AURORA_ACCOUNTING_DAYS
WHERE (((AURORA_ACCOUNTING_DAYS.ODATE) Between [begin date] And [end
date]));

:

Post the SQL of the query you are trying to run. You may also need
to post
the Model Build Count, if that is a query.

Troubleshooting.
Just try
DCount("*","[Model Build Count]")

If that errors, then the error has something to do with [Model Build
Count].


Thanks John. This should be so easy and I getting so frustrated.
I tried
your suggestions and I either get #error in every field result or I
got
the
following error msg when running the query, "the expression you
entered as
a
query parameter produced this error, "the object doesn't contain
the
automation object "begin date", which is my parameter. I've tried
adding
the
parameters (begin date & end date) in the query and still get the
same
message.

Maybe I'm not understanding what DCount does. I just want a column
that
numbers the records sequentially. I would assume then, that it
doesn't
matter which field I name in the DCount function, as long as it's
not
null?
Thanks again

:

Since your query or table name has spaces, you have to use []
around the
name.
If ResourceID is a Text field then you need to surround it with
quote
marks
or apostrophes.

Try one of the following.

DCount("resourceID","[Model Build Count]","resourceID <=""" &
[resourceID] &
"""")
DCount("resourceID","[Model Build Count]","resourceID <='" &
[resourceID]
&
"'")

I've tried unsuccessfully, using DCount and a subquery to number
records
in
my query.

In a query called "ModelCount", I'm trying to number the records
returned
from the "Model Build Count" query using the resourceID field,
which is
a
text field. Model Build Count is a paramenter query.

I've tried DCount("resourceID","Model Build Count","resourceID
<=" &
[resourceID]) and other ways of writing this, but I keep getting
error
messages. Any help is appreciated. Thanks.
 
Back
Top