DCount question

jeo

Registered User.
Local time
Today, 16:22
Joined
Dec 26, 2002
Messages
299
I have a DCount() statement that checks to see if records (in a qryCheck) meet that condition. I have it where if DCount(…) > 0 then do something.
What I would like to be able to do is to display all records where conditional DCount() check = 0 on a certain form.
Is this at all possible? I can't seem to figure out how to do:
Show all records where DCount(...) = 0.
Thank you.
 
Last edited:
Thank you for posting.
Do you think that something like this code would work?
I can't really program that well, so I need some help with this code, but I think that code would probably run faster than a query would.

Dim rstOrig As DAO.Recordset
Dim rstNew As DAO.Recordset

Set rstOrig = CurrentDb.OpenRecordset("tblProjectStaff", dbOpenDynaset)
Set rstNew = CurrentDb.OpenRecordset("tblAvailableDates", dbOpenDynaset)
rstOrig.MoveFirst

If DCount(.............) = 0 Then
Do
rstNew.AddNew
rstNew("ProjectStaffID") = rstOrig("ProjectStaffID)
rstNew("StaffID") = rstOrig("StaffID")

rstNew.Update
rstOrig.MoveNext

Loop Until IsNull(ProjectStaffID)(i'm not sure when to stop looping through this is there something like an EOF?).
Could someone please help me with the code. What I want to do is create records in my new table where DCount() = 0. Then I can create a query from this new table and create a form.
Or may be this is a bad idea to begin with? Any help would be reatly appreciated.
Thank you!
 
I’ve attached a sample db that scouser has helped me with the past.
On the form frmStaffActivityDetail there is a Before_Update event which contains a DCount statement:
If DCount("ID", "qryStaffActivityChk", "ActivityStartDate = Forms!frmStaffActivityDetails!ActivityStartDate AND StaffID = Forms!frmStaffActivityDetails!StaffID") > 0 Then …

What I want to do is to create records whether in a new table or just in a query where this DCount statement = 0.
What I want to accomplish through this is to be able to view people who are available on that particular day.

I hope that this is a little better explanation and you will be able to help me a little better.
Thank you for all your help!
 

Attachments

Users who are viewing this thread

Back
Top Bottom