Hi -
A couple of points to help you out.
first, since the query you are using is already a summation query, the
you
don't want the DCount function, you need DLookup, something like this:
iBookings = Dlookup("[FieldName]","[queryName]","Criteria")
where FieldName is the name of the field in your query that contains the
total you want to check,
QueryName is the name of your query.
"Criteria" is a text string which specifies which record in the query you
are
referring to. It is just like an SQL "where" clause, but without the
word
where. It can refer to more than one field in the query, and in your
case it
looks like it will need three - Date, Time and Venue - and because you
are
using date, the syntax in the query is a bit tricky if the data type of
the
field in the query is Type Date. Time and Venue are presumably text.
Your criteria string could be in a variable:
Dim CriteriaSQL as String
CriteriaSQL = "LectureDate = #" & format(me![LectureDate],"mm-dd-yyyy") &
"#
and LectureTime = '" & me![LectureTime] & "' and Venue = '" & me!
[LectureVenue] & "'"
So you would use:
iBookings = Dlookup("[FieldName]","[queryName]",CriteriaSQL)
when John V. writes {the maximum}, he means that you have to replace {the
maximum} with a number that is the actual number of places available. If
this is a constant value, then you can just put it in, but if it can
vary -
which I suspect will be true if you have different venues - then you have
to
find a way to to that.
Hint: A Lookup on a table listing Venues and places available in each
might
be used.
HTH
John G.
For John V. : This is what I would do; you may well know of an easier way
to
do this - do let us know!
J.
Hi John
Thanks for replying to my post but I'm still lost, hopefully you can
help me
some more.
I've typed the code in as you've written, including the correct query
name,
however, I'm not sure what "somecriteria" means!
Anyhow, it does work, however, it seems to come up for any date and any
quantity, I know I'm doing something wrong but I just don't know what.
The query I'm running adds up a specific venue with dates and times to
give
an overall total (LectureQty), I've tried including this as the
"somecriteria" but it makes no difference and every time I use {} these
symbols it comes up with a compile error: Invalid character - I need
help
please.
Being new to Access I'm not actually sure how to phrase this but here
goes:
[quoted text clipped - 18 lines]
John W. Vinson [MVP]