I have a subform that is based directly on a table called tbl_WizardReqEnv.
It is a stagnant set of 5 records that only serve as a switch.
All I want to do is determine that at least one or more of these records
"req" field which is a yes/no field - is checked or not.
so I have a routine as follows:
if DCount("*", "tbl_WizardReqEnv", "[Req] = " & -1) < 0 then
msgbox "Please select at least one environment before proceeding"
end if
But for some reason, it's always off by a refresh or something -- What can
I do to assure my DCount gives me the results I'm looking for as soon as I
make changes to the subform?
Thanks
tina - 28 Nov 2005 05:21 GMT
did you type the expression correctly in your post? if no record in a domain
match the specified criteria, a DCount() will return 0, not " less than
zero". so the expression
DCount("*", "tbl_WizardReqEnv", "[Req] = " & -1) < 0
will always be False. try changing your expression to "< 1" or "= 0".
btw, the DCount will also work with criteria
DCount("*", "tbl_WizardReqEnv", "[Req] = True")
hth
> I have a subform that is based directly on a table called tbl_WizardReqEnv.
> It is a stagnant set of 5 records that only serve as a switch.
[quoted text clipped - 12 lines]
>
> Thanks
John Vinson - 28 Nov 2005 06:25 GMT
>But for some reason, it's always off by a refresh or something -- What can
>I do to assure my DCount gives me the results I'm looking for as soon as I
>make changes to the subform?
In addition to Tina's suggestions, you need to be sure that the record
on the form has in fact been saved to the table at the time you call
DCount. If the code is on a subform event, the record may still be
"tentative" on the form, not yet saved; to force a save add
If Me.Dirty Then Me.Dirty=False
prior to the code that checks for the count.
John W. Vinson[MVP]