Thanks Rick for the explanation. I kinda thought that was what it did, but
I'm having a problem with this and I haven't a clue what to do about it. I've
read many of your answers to mine and other's questions and from that I know
you're extremely knowledgeable about Access. So, maybe you can answer this. I
have a main form that enters info on an owner. They then press a button to go
to subform to enter info on an animal they have. What I'm attempting to do is
keep a running count of the number of animals and display it on the main
form. It works fine, except that if you enter a new owner on the main form,
use the command button to go to the animal sub-form and enter the animal
info, when you return to the main form it's not reflecting this newly entered
animal. The count still is 0. If you go out of the main form, and come back
for this owner the correct number is there. I'm using this code:
CountOfAnimals = DCount("*", "tblAnimals", "[OwnerID_AnimalTbl] = " &
Me.OwnerID)
in a sub routine called ToggleLink_Click that I think was created when I
used the wizard to create the main form and subform and this code works fine
there. But, if I put this same code in the On Current Event, I get this error
message:
Syntax error (missing operator) in query expression '[OwnerID_AnimalTbl] = ".
I don't understand why the code works fine in one place and in another it
generates an error message. And, that's not even a query expression, is it?
While I've learned a lot over the past few months using Access and looking
thru this discussion group for answers, I'm still learning and when things
like this happen I haven't a clue where to look or what to look for. Would
you please enlighten me on why this works in one spot and not in the other?
Thank you for your time, and especially, your patience dealing with people
like me who are forever asking yall questions. Believe me when I say that I
am very appreciative of yall sharing your knowledge with us.
Thanks,
RandyM
Rick Brandt said:
WCDoan wrote:
Could someone please explain to me what exactly this is for? From
what I read, I thought that you could put statements here that you
wanted to happen each time a new form was generated. I must be
confused about this because somethings I can put there and there's
not a problem, but other statements that work fine in other areas
cause errors when I place them in the On Current Event. Could someone
shed some light on how to use this?
Thanks,
RandyM
I'm not sure what you mean when you say "...each time a new form was
generated."
OnCurrent fires whenever the form displays a record and this includes when
the form is first opened.
So if I open the form to "record 1 of 10" then the current event fires when
that first record is displayed. If I then navigate to a different record
*by any means* then the event fires after each different record appears. It
would also fire if I stayed on record 1 and refreshed or requeried the form.
EXAMPLE:
I want to hide a certain control on the form when a different bound control
on the form contains a certain value. I would need to run that code every
time a different record is navigated to because each record could
potentially have a different value in the bound control being tested.