Missing Count

G

Guest

I am trying to put together a registration form for summer classes. The
student puts in all info required and selects the courses they'd like to take
from a combo box. There are four class periods so they can take up to four
classes. The form calculates tuition, fees etc and prints just like it's
supposed to. So far so good. Once all the students have registered and we
know how many kids we'll have for each subject, the clerks will go back and
determine how many classes will be needed for a particular subject and assign
rooms, times and teachers - creating the actual course schedule. This
schedule is entered in a ScheduleTable. Once the schedule is set, the clerks
go back to the Registration form to assign individual students to their
classes. There are buttons on the Reg. form, next to the subject combo boxes.
They click the button and a box pops up(ScheduleDetail1-4) showing all the
classes in the ScheduleTable that match that subject. This all works fine.
Never knowing when to leave well enough alone, I thought it would be nice to
show the clerks a count of how many students have been assigned to the
classes. I added a field to the pop-up form called ClassCnt and I have a
query that consolidates my four periods and I thought all I had to do was a
simple DCount but I can't get it to work.
The query runs On Open of the pop-up and the control source of ClassCnt is
=DCount("*","ClassRosterConsolidated","[class]=FORMS!ScheduleDetail1![ClassNo]")
The really strange thing is that if I click in my ClassCnt box, the correct
count shows up. If you don't click in the box, it's empty. I figure that
means I've got my code firing in the wrong event. I've tried every putting my
DCount in every On Open, On current, Got Focus etc. that I can find. I even
tried moving focus to the ClassCnt but nothing works. What am I doing wrong
here?

TIA
Lynne
 
B

Baz

You seem to be misunderstanding how calculated controls and queries work.
You only need to set the control source of the text box, you don't need ANY
code in ANY event procedure to make this work.

Since I don't know exactly what your code is doing I can't say for sure that
this is related to your problem, but it certainly will not be helping.
 
G

Guest

Baz said:
You seem to be misunderstanding how calculated controls and queries work.
You only need to set the control source of the text box, you don't need ANY
code in ANY event procedure to make this work.

That's what I thought. I have the control source of my ClassCnt field set to

=DCount("*","ClassRosterConsolidated","[class]=FORMS!ScheduleDetail1![ClassNo]")
It's counting the number of records in the table where the class number
matches the class number on the ScheduleDetail form. AND IT DOES. If I move
the cursor to the ClassCnt field and click in it - the correct count appears.
So it's doing the calculation. I just don't get why it isn't showing in the
field without clicking in the field.
 
B

Baz

Are you using Access 2007? There's another post somewhere nearby where
someone else is complaining about exactly the same problem i.e. a calculated
control which doesn't display until you click on it. Beginning to wonder if
this is an Access 2007 bug.

Lorien2733 said:
That's what I thought. I have the control source of my ClassCnt field set to=DCount("*","ClassRosterConsolidated","[class]=FORMS!ScheduleDetail1![ClassN
o]")
It's counting the number of records in the table where the class number
matches the class number on the ScheduleDetail form. AND IT DOES. If I move
the cursor to the ClassCnt field and click in it - the correct count appears.
So it's doing the calculation. I just don't get why it isn't showing in the
field without clicking in the field.
 
G

Guest

Baz said:
Are you using Access 2007? There's another post somewhere nearby where
someone else is complaining about exactly the same problem i.e. a calculated
control which doesn't display until you click on it. Beginning to wonder if
this is an Access 2007 bug.
Actually, I'm still using 2003. I fixed whatever it was though. I got
tired of staring at it so I just took everything out - the control, the code
and anything that touched it and started over. Everything works now so I
assumed it was some picky little syntax error or something that I did
correctly the second time through. Thanks for all your help anyway. You guys
are great.
 

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

Similar Threads


Top