on change event

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

Guest

Hi Everyone
I created a refresh button that requery one of the fields on subform in the
main form. It works perfectly when I click this button. I'd like to use this
code every time I go to a different record on the main form. I pasted it
into "on change" event of my ClientID on main form, but then it does not
work. Any ideas where I can place this code?

thanks
Barb
 
Try moving the requery to the AfterUpdate event of the ClientID control. The
change event fires for every keystroke which is not really what you
intended. Also, make sure that you are correctly referencing the control on
the subform -

me.sfrmSub1.form.cboMyControl.requery

Note that 'sfrmSub1' must be the name of the subform control on the main
form. This is not necessarily the same as the name of the form object that
is referenced in the ControlSource of the subform control. To be sure, open
the main form and click once on the subform then check the name property
under the Other tab. Whatever you find there is what belongs in place of
sfrmSub1.
 
Barb said:
I created a refresh button that requery one of the fields on subform in the
main form. It works perfectly when I click this button. I'd like to use this
code every time I go to a different record on the main form. I pasted it
into "on change" event of my ClientID on main form, but then it does not
work. Any ideas where I can place this code?

The Change event is inappropriate, use the form's Current
event instead.
 
Sorry, mis-read - the current event is correct (of course!) - but you
probably also want the AfterUpdate event of the control so that the subform
matches the main form when records are added or edited.
 
Sandra said:
Sorry, mis-read - the current event is correct (of course!) - but you
probably also want the AfterUpdate event of the control so that the subform
matches the main form when records are added or edited.


Interesting. I think I only answered the question as asked
without thinking about the broader issues.

However, with the two if us working together, I think we
managed to cover all the bases ;-)
 

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

Back
Top