There you go: you do have parameters like:
[forms]![frmSuspensions]![StartDate]
in your lower level query.
What I prefer to do is to create the query statement dynamically.
If necessary, you can then assign the literal dates to the SQL property
of a
QueryDef that you use for the purpose, e.g.:
strSql = "SELECT ... WHERE SomeDate Between #1/1/2010# And
#1/31#2010#;"
CurrentDb.QueryDefs("Query1").SQL = strSql
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Hi Allen
Thank you for getting back to me, and again I apologize for how this
has
been communicated. Originaly, I thought that all I needed was a simple
Access
function to do the trick (I am not a programer). So intially, I gave a
simplistic example to help clarify what I needed. I also tried to
problem
solve this on my own and posted another related question that I thought
would
help solve the issue. Little did I know that I would require a complex
module.
I think that C) is the problem here for me. Here is my SQL:
From PrevSuspConcat
SELECT ConcatRelated("[DateLength]","[QryPrevious]") AS PreSuspList;
From QryPrevious
SELECT QryReportSource.SuspLength, QryReportSource.StartDate,
QryReportSource.IDnumber, CStr([StartDate] & " - " & [SuspLength]) AS
DateLength
FROM QryReportSource
WHERE (((QryReportSource.StartDate) Between
[forms]![frmSuspensions]![StartDate]-1 And
[forms]![frmSuspensions]![StartDate]-305) AND
((QryReportSource.IDnumber)=[forms]![frmSuspensions]![IDNumber]));
If I get rid of the WHERE stuff, everything works perfectly ... so it
is
not
a combined field issue or a Date/Text issue like I had thought.
Unfortunately, I need the filtters (WHERE) from the current record in
the
form to provide the right data. But some how these filters prevent the
function from working.
Do know if there is a possible work around to this delema?
I have tried to query just the one field [DateLength] and then use your
function on that but this also didn't work, I get the same error.
I tried to put the values that I needed into a table using an update
query,
but I could get the query to update it always comes back zero rows.
:
It should be fine if:
a) [Startdate] and [SuspLength] are fields in the source table,
b) You have an alias name in the Field row in front of the expression,
e.g.:
Expr1: [Startdate] &" - "& [SuspLength]
c) You don't have any criteria under this calculated field, nor
criteria
under any further expressions that use this one.
Perhaps you can temporarily remove some things from the query until
you
get
the function returning results, and then start putting them back as a
way
of
pinning down where the problem is.
To answer your specific question you could use Str() to force the
type,
but
I would not have thought that was necessary:
Expr1: Str([Startdate] &" - "& [SuspLength])
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Hi Allen
I have been experimenting with the ConcatRelated function
In my query "QryPrevious" , I have a combined field consisting of
two
fields
called "DateLength".
[Startdate] &" - "& [SuspLength]
Startdate is a date field from a table.
The results of QryPrevious are
12/2/2009 - 3 day
12/4/2009 - 2 day
12/8/2009 - 3 day
I would to combine them into a single field, called [Alldates]. Like
the
following
12/2/2009 - 3 day, 12/4/2009 - 2 day, 12/8/2009 - 3 day
What can I do with the [Startdate] &" - "& [SuspLength] so it
becomes
TEXT
so that the ConcatRelated can resolve it as a single value?
Like it works with
A
B
C
to A,B,C
Thanks for looking at this.
:
The request for parameters means there are 2 names in the query
that
Access
can't resolve.
Does the query contain names such as:
[Forms].[Form1].[Text0]
If so, those are the parameters. That won't work for in the context
of
the
DAO code.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Hi Allen
I can't get it to work! I get an error that says error 3061: Too
Few
Parameters. Expected 2.
I have the following in a textbox named "grades" in a report
named
"RptOutputForm" who's source is "QryReportSource".
The query that supplies the information for this specific text
box
is
"QryPrevious"
=ConcatRelated("Letter","QryPrevious")
I have only one field "Letter" of values in the query
"QryPrevious"
A
B
C
I am unsure as to what should be imputed in for the 3rd, and 4th
values
of
the string (I am assuming that this is the source of the error).
:
This may do the job for you:
Concatenate values from related records
at:
http://allenbrowne.com/func-concat.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
I have a query call QryFind that produces one field with many
records.
Simply
I need to Concatenate the results to display in a text box on
a
form.
From
A
B
C
I need
A, B, C
How do I do this?
.
.
.
.