Debug?

jeo

Registered User.
Local time
Today, 03:01
Joined
Dec 26, 2002
Messages
299
Is there a way to debug the following statement:
If DCount("ID", "qryStaffActivityChk", "ActivityStartDate = Forms!frmStaffActivityDetails!ActivityStartDate AND StaffID = Forms!frmStaffActivityDetails!StaffID") > 0 Then

I did a msgbox(DCount(...)) and that works, but it only gives me a count of the previous statement.
What i want to see is actual values for ActivityStartDate in qryStaffActivityChk that are being checked.

Is there a way to do that somehow?
Thanks.
 
Hello

Hi Jeo.
Is there a way to debug the following statement:
If DCount("ID", "qryStaffActivityChk", "ActivityStartDate = Forms!frmStaffActivityDetails!ActivityStartDate AND StaffID = Forms!frmStaffActivityDetails!StaffID") > 0 Then

If DCount("ID", "qryStaffActivityChk", "ActivityStartDate = Forms!frmStaffActivityDetails!ActivityStartDate AND StaffID = Forms!frmStaffActivityDetails!StaffID") > 0 Then

So all I am doing here is saying how many (DCount) records (ID)
within (qryStaffActivityChk) which have a (ActivityStartDate AND StaffID) equal to the current record (Forms!frmStaffActivityDetails!ActivityStartDate).

If that figure is more than 0 (>0) then run the next piece of code:

DoCmd.OpenForm "frmStaffChk", acNormal, , "[ActivityStartDate] =
Forms!ActivityStartDate!ActivityStartDate"

This opens the form frmStaffChk (which has a record source of qryStaffActivityChk) and limit the records displayed to where the ActivityStartDate is the same as the service time of the current record on the form.

What are you actually looking to achieve?
Phil.
 
For some reason I don't think this piece is working correctly.
So all I am doing here is saying how many (DCount) records (ID)
within (qryStaffActivityChk) which have a (ActivityStartDate AND StaffID) equal to the current record (Forms!frmStaffActivityDetails!ActivityStartDate).
I don't think it's looking up the ActivityStartDate and StaffID in that query because when I type in the same start date for one and same person it doesn't give me an error and I know it should.
So I wanted to see what values was it actually comparing the
Forms!frmStaffActivityDetails!ActivityStartDate to.
 
Error

Try again. Delete all entries from the tblStaffActivity.
Select a Staff Member and assign them an Activity.

Enter a ActivityStartDate 01/01/2005
Enter a ActivityEndDate 01/02/2005

Repeat a second time and the error will be generated.
However you are right it does not work properly. If you amend the ActivityEndDate on the second entry the error is not generated. This led me to think it was ignoring the code also?

I am unsure how to resolve as I used the code for a different purpose which worked for me. I tried to modify it to suit your requirements not fully understanding what they were.

Post a sample DB + what you are looking to achieve. One of the many experts will explain where I have gone wrong!!

Good Luck,
Phil.
 
This is what I could come up so far.
It’s not working, but I think that this is the beginning of what I need.
I check (by pushing the command button for now) each and every new date that is being entered into the database.
There are 4 conditions I check against: (anything starting with qry – value from the query and anything starting with form – value from the form)

qryStartdate < formStartdate And qryStartdate < formEnddate
OR qryStartdate > formStartdate and qryStartdate > formEnddate

AND
qryEnddate < formStartdate and qryEnddate < formEnddate
OR qryEnddate > formStartdate and qryEnddate > formEnddate

I put that in my DCount function as criteria and see how many records there are with this criteria, if there are > 0 then a person is NOT available for new set of dates
ELSE
That person is available for that set of dates.
I also put these statements into my check query.
So anyone, please tell me if I’m on the right track…I’ve been trying to get this figured out for a while now and still can’t.
Thank you for all your help!
 

Attachments

Also, I'm wondering if I can have a conditional statement within DCount function.
Because this date checking criteria (qryStartdate < formStartdate And qryStartdate < formEnddate
OR qryStartdate > formStartdate and qryStartdate > formEnddate
AND
qryEnddate < formStartdate and qryEnddate < formEnddate
OR qryEnddate > formStartdate and qryEnddate > formEnddate)

returns true or false and what does Access do with that?
Can it do this:
If DCount("ID", "qryStaffActivityChk", "(....conditional datecheck...And Staffid = Forms!frmStaffActivityDetails!StaffId)"


Thanks!
 

Users who are viewing this thread

Back
Top Bottom