DCount & record selector

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using DCount in a form to count number of animals (Thank you Klatuu) and
this works fine. I have a lookup combo box that the DCount statement is in.
Problem is if I use the record selector to change records, the DCount remains
the same. Where or what is the 'event trigger' for using a record selector to
change records? Where could I put the DCount so that the count would change
if I changed records?

Thanks,
RandyM
 
If you are using the built in Access navigation buttons, there is no event
for them. If you are using command buttons to create your own navigation, it
would be in the Click event; however, the best place would be in the form's
Current event.
 
Klatuu, thanks for responding. I'm using the DCount like you suggested for
another question I had and I copied the following from in the after update
event in the combo box lookup and put it in the On Current event of the form.

CountOfAnimals = DCount("*", "tblAnimals", "[OwnerID_AnimalTbl] = " &
Me.OwnerID)

When I use this I get this error message
Syntax error (missing operator) in query expression '[OwnerID_AnimalTbl] = ".

By the by, I'm using Access's navigation buttons. Any ideas bout what's
happening?

Thanks
RandyM
 
The following is is the code that keeps getting the error message: I've moved
the CountOfAnimals statement - before the If Child.... and after the If Child
and it still comes up with the error - Syntax error (missing operator) in
query expression '[OwnerID_AnimalTbl] = ".
I put the same code, changed to reflect the different names, in the On
Current of a subform of this form and it works fine. I don't understand
what's happening and why. Can you shed some enlightenment my way?

RandyM

Sub Form_Current()
CountOfAnimals = DCount("*", "tblAnimals", "[OwnerID_AnimalTbl] = " &
Me.OwnerID)
On Error GoTo Form_Current_Err

If ChildFormIsOpen() Then FilterChildForm

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub

WCDoan said:
Klatuu, thanks for responding. I'm using the DCount like you suggested for
another question I had and I copied the following from in the after update
event in the combo box lookup and put it in the On Current event of the form.

CountOfAnimals = DCount("*", "tblAnimals", "[OwnerID_AnimalTbl] = " &
Me.OwnerID)

When I use this I get this error message
Syntax error (missing operator) in query expression '[OwnerID_AnimalTbl] = ".

By the by, I'm using Access's navigation buttons. Any ideas bout what's
happening?

Thanks
RandyM

Klatuu said:
If you are using the built in Access navigation buttons, there is no event
for them. If you are using command buttons to create your own navigation, it
would be in the Click event; however, the best place would be in the form's
Current event.
 

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

Access Dcount function in access 0
Access Dcount (multiple criteria) 3
Counting filtered records... 7
Still struggling with DCount 8
DCount problem redux 4
dcount 1
Speeding up "1 of X" 0
Access MS Access DCount function problem 0

Back
Top