In news:867135C7-89BD-467E-99AA-(E-Mail Removed),
MarkS <(E-Mail Removed)> wrote:
> Hi,
> I use this code to get the hours in a contracts
>
> Set rst1 = CurrentDb.OpenRecordset("Select count(PeriodNo)/2 as hours
> from IERSPROD_TOFFERSLOT Where OfferCD = '" & sOfferCD & "'")
> rst1.MoveFirst
> lHours = rst1(0)
>
> there can only be one answer. Is there a way to load the hours into
> 'lHours' with out using a recordset
Even if you call DLookup or DCount, there'll still be a recordset at
work; it'll just be inside the function instead of outside it. I think
you'll do better with your own recordset.
Note, though, that this line:
> rst1.MoveFirst
.... is unnecessary. When you first open a recordset, you're at the
first record already, unless the recordset is empty.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)