Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Timing of DCount

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jonefer - 28 Nov 2005 04:43 GMT
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]    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.