I am grateful that you are taking the time to try to solve this.
> I think a query along these lines will return the cars that
> are available on the specified day and time. (The subquery
> finds cars that are busy and the Left Join and Is Null
> criteria excludes them.)
> ...
That was the same I was going for with my strCriteria in the code:
strCriteria = "[Day] = '" & strDay & "' AND NOT [Car] IN " _
& "(SELECT [Car] FROM [qryTimes] WHERE [Day] = '" & strDay _
& "' AND [TimeMax] > #" & datFrom & "# AND [TimeMin] < #" &
datTo & "#)"
I am not sure though, why you have the last "And X.TimeMax < Forms!
theform.txtStart".
> Then, I think another query can then find the data for the
> previous and next route:
[quoted text clipped - 9 lines]
> WHERE X.Car = G.Cars)
> Or TimeMin Is Null)
I am sorry to say, it doesn't work. I do not get all the cars
available. TimeMax and TimeMin are never null in GetCars. And the
times (and adresses) I want returned, are not neccessarily max and min
for the given car on the given day. If for instance the car drives 5
routes that day, and is available in the requested time interval
between route 2 and 3, I would like returned TimeMax and AdrMax for
route 2 (so I know when and where it is available from) and TimeMin
and AdrMin for route 3 (so I know when it is no longer available, and
where it needs to be at that time).
> ...so I will leave it to you to test
> this idea and decide if you want to pursue it or go back to
> using code to calculate the data (which may be even more
> complicated).
Actually the code in my original post gave the correct results, only
since they came out as variables, I could only present them in the
immediate window or a message box.
I am beginning to think that if I can get the results into a none-
editable form by creating an adhoc recordset, maybe I should use this
instead of a report. After all, I can give the form a white background
and set all fields to locked, maybe I can make the user think it is a
report?
> Or maybe someone else will get interested in the problem and
> jump in with a cleaner/efficient idea.
Any help is more than welcome!
Best regards
Aino
Marshall Barton - 24 Mar 2008 21:00 GMT
>I am grateful that you are taking the time to try to solve this.
>
[quoted text clipped - 11 lines]
>I am not sure though, why you have the last "And X.TimeMax < Forms!
>theform.txtStart".
My thought was to also eliminate any records where the
MaxTime was before the start time since they seem like they
are irrelevant to the question.
>> Then, I think another query can then find the data for the
>> previous and next route:
[quoted text clipped - 12 lines]
>I am sorry to say, it doesn't work. I do not get all the cars
>available. TimeMax and TimeMin are never null in GetCars.
You're right, there won't be any Null times, so you can get
rid of those Or expressions. Like I said Access went south
before I could test all that stuff so I never got a chance
to test it. The idea I was working toward is to eliminate
the entries with availablity that does not include the time
requested.
> And the
>times (and adresses) I want returned, are not neccessarily max and min
[quoted text clipped - 4 lines]
>and AdrMin for route 3 (so I know when it is no longer available, and
>where it needs to be at that time).
Right. That was the intent of the
And X.TimeMax < Forms!theform.txtStart
criteria in the first query.
>> ...so I will leave it to you to test
>> this idea and decide if you want to pursue it or go back to
[quoted text clipped - 10 lines]
>and set all fields to locked, maybe I can make the user think it is a
>report?
If you have the desired recordset, then assigning it to a
form's Recordset property might be all you need.

Signature
Marsh
MVP [MS Access]
Aino - 30 Mar 2008 15:13 GMT
> If you have the desired recordset, then assigning it to a
> form's Recordset property might be all you need.
By now I have given up on this as well.
Since it is a fabricated recordset, it is not possible to use it for a
form.
I have tried setting certain attributes as recommended by Lyle
Fairfield in <http://groups.google.fr/group/comp.databases.ms-access/
msg/ae637cf71a8d8360>.
I have tried going though a stream as described by Florian Esser in
<http://groups.google.fr/group/microsoft.public.access.formscoding/msg/
d59c62f523b1fbbc>
I have tried a sub converting the fabricated recordset to something
looking like a bound recordset, code delivered by Steve Jorgensen in
<http://groups.google.com/group/comp.databases.ms-access/msg/
de67ac684186964e>
All of it to no avail. I am using MS Access 2000. I believed the
difficult part would be to get the right data, I would never have
thought that getting the data presented in something else than a
message box would be the killing part!
It seems I have to construct an SQL to solve this. I just feel very
disillusioned rigth now.
Best regards
Aino