By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,790 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,790 IT Pros & Developers. It's quick & easy.

Addressing onCurrent Event of a SubForm

P: 3
I would like to use the oncurrent event of a subform. The subform class seems to offer onEnter and onExit only, so I tried up to set the event handling routine programatically. It works fine with a macro:

MySubForm.Form.OnCurrent = "MyMacro"

But what about using VBA code? What procedure name does Access expect after having found

MySubForm.Form.OnCurrent = "[Event Procedure]" ?

MySubForm.Form.Name is "myQuery" so I tried up to define

myQuery_Current()
' .. do something ..
End Sub

but nothing happens. Any idea what could be wrong?
Jan 9 '08 #1
Share this Question
Share on Google+
5 Replies


jaxjagfan
Expert 100+
P: 254
I would like to use the oncurrent event of a subform. The subform class seems to offer onEnter and onExit only, so I tried up to set the event handling routine programatically. It works fine with a macro:

MySubForm.Form.OnCurrent = "MyMacro"

But what about using VBA code? What procedure name does Access expect after having found

MySubForm.Form.OnCurrent = "[Event Procedure]" ?

MySubForm.Form.Name is "myQuery" so I tried up to define

myQuery_Current()
' .. do something ..
End Sub

but nothing happens. Any idea what could be wrong?
I think you were looking at the subform control that contains the subform when you stated "OnCurrent" not available. If you view the properties of the actual subform (not the container it is in) you will find all of the same events and properties of your main form.
Jan 9 '08 #2

P: 3
There is no other form within the subform container but a query. Probably that is for there are no other properties or events accessible "within" the container. Seems the form object I was able to use its onCurrent event via a macro was then automatically created by Access?
Jan 9 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
Yes, if you base your subform on a table/query Access does generate a form (a subform has to be based on a form) and you can then access the properties of this generated form from within Design View by clicking on its little "magic box" in the upper left-hand corner. You can actually do the same thing and then go into it's code window as well. Access also places the generated form in the forms tab of the Objects Dialog box, naming it using the YourQueryName Subform format.

Welcome to TheScripts!

Linq ;0)>
Jan 9 '08 #4

P: 3
For some reason, I am not able to access any properties of the subform object in Design View. The "magic box" called after focusing the subform showed only the property window of the main form, not the subform. And neither the Objects Dialog box nor the combo box with the object list contain the embedded subform.

However, I've got fixed the problem now by using a macro which is calling a VBA function. Pretty ugly ... but it does work. (Why on earth did MS not provide a way for setting event routines in code directly when they managed it for the macros???)

Thanks a lot for your assistance!

Tom
Jan 9 '08 #5

missinglinq
Expert 2.5K+
P: 3,532
Another approach would be to make a form (even if you simply use the Forms Wizard) using the query as your recordset, then base the subform on this form.

Linq ;0)>
Jan 9 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.