Best way to know if a control in a datasheet sbfrm is null

D

David Portwood

I have a record for each contractual document (let's leave it general,
please). Actions are generated against that document. When all actions have
been resolved, the "owner" of the contractual document indicates completion
of document processing by filling in a DateCompleted field.

My Documents table is linked 1:M to an Actions table and I have a
corresponding form/subform. I want the DateCompleted field in the main form
to be disabled while there are any open Actions in the subform. To check for
this, what I do now is run a DCount() against the Actions table. This works,
but it seems unnecessarily time consuming to run a domain aggregate function
when the records are right there on the subform. It is rare to have more
than five actions for any one document.

The subform is in datasheet view, so I can't put a calculated field. I tried
code like the following in the main form's Current() event:

With Me.Actions.form.recordset
.findfirst "criteria indicating an open action"
Me.DateCompleted.enabled = .no match
end with

Doesn't work, I forget specifically why now. Anyway, the DCount() works, but
I'm hoping someone might have a faster way to do this.
 
A

Allen Browne

The DCount() is probably better than looping through the records of the
subform. It works reliably, which may not be the case for the subform (e.g.
if filtered, or timing issues if it were not loaded yet.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top