![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm trying to use the event when a person moves to a different form by clicking on the built in Access application tabs. Is there something I can reference or does it require some kind of subclassing/hook api calls? Thanks |
#3
| |||
| |||
|
|
You can use the OnDeactivate event. |
#4
| |||
| |||
|
|
You can use the OnDeactivate event. Hello Imb, Aha. Now I am forced to make an event for each form. Trying to automate what tab the ribbon moves to based on the access application tab. |
|
Okay, thanks. Access could use a rewrite of it's event system imho. There are no top level application events to tap into, no 'after delete' event, record saves w/ a 'dirty=true', it's all quite ridiculous. |
#5
| |||||
| |||||
|
|
Aha. Now I am forced to make an event for each form. Trying to automate what tab the ribbon moves to based on the access application tab. You don't have write a event for each form, put a function or a sub in a module and call it from the form. Enter "=YourFunctionName()" in the deactivate event . |
|
Okay, thanks. Access could use a rewrite of it's event system imho. There are no top level application events to tap into, no 'after delete' event, record saves w/ a 'dirty=true', it's all quite ridiculous. What would those events look like? *Would you put after delete and record save code in both the form and the application events? |
|
How would the application events know which form or report to control? |
|
With the current event model the form manages the data. |
|
When you click a tab you get Control, Record and Form events on the form you are leaving and Form, Record and Control events on the form you are entering. |
#6
| ||||
| ||||
|
|
Aha. Now I am forced to make an event for each form. Trying to automate what tab the ribbon moves to based on the access application tab. You don't have write a event for each form, put a function or a sub in a module and call it from the form. Enter "=YourFunctionName()" in the deactivate event . Yes you are right, but that is in effect inserting an event stub in each form/report, even if it is just to call the same routine. The more direct way is to be able to use an application tab event. That way you don't need to remember to insert that de/activate event stub in each new form/report. I will be walking away from this db at some point but the users may still be creating new reports and will have to remember this (arbitrary) formality. |
|
Okay, thanks. Access could use a rewrite of it's event system imho. There are no top level application events to tap into, no 'after delete' event, record saves w/ a 'dirty=true', it's all quite ridiculous. What would those events look like? Would you put after delete and record save code in both the form and the application events? I initially intended the form event, but at the application level could be useful as well. At present I create a right-click/context menu to delete the record AND hook into the delete key down event to call a routine that deletes the record. I need to do some post delete re-querying of the form so it updates correctly. OnDelete cannot re- query the form AFTER the delete. How would the application events know which form or report to control? Well, if you used an application level AfterDelete (or any other application level event) it would apply to ALL open forms (etc). |
|
With the current event model the form manages the data. Say you have two forms viewing the same table open in two tabs. You type in the first form, tab (click) to the next form. Now try typing data in the second form. You can't. The data is still locked from the first edit. You must detect (on the de/activate of Each form) when it is de/activated and save the previous record before editing the new form because it won't automatically save. And to save that record we get to the 'dirty=true/false' silliness. And I say it's silly because there is no form/control level auto-save method. |
|
When you click a tab you get Control, Record and Form events on the form you are leaving and Form, Record and Control events on the form you are entering. Not saying it's completely wrong, I'm just saying it can be more orthogonal AND allow the developer to tap into the higher level event system that is already there, just not exposed to us. |
#7
| ||||
| ||||
|
|
Aha. Now I am forced to make an event for each form. Trying to automate what tab the ribbon moves to based on the access application tab. You don't have write a event for each form, put a function or a sub ina module and call it from the form. Enter "=YourFunctionName()" in the deactivate event . Yes you are right, but that is in effect inserting an event stub in each form/report, even if it is just to call the same routine. The more direct way is to be able to use an application tab event. That way you don't need to remember to insert that de/activate event stub in each new form/report. I will be walking away from this db at some point but the users may still be creating new reports and will have to remember this (arbitrary) formality. Not only a new programmer but also you after a number of years of not working the the application. That is why you document the application and test changes. |
|
Okay, thanks. Access could use a rewrite of it's event system imho. There are no top level application events to tap into, no 'after delete' event, record saves w/ a 'dirty=true', it's all quite ridiculous. What would those events look like? *Would you put after delete and record save code in both the form and the application events? I initially intended the form event, but at the application level could be useful as well. At present I create a right-click/context menu to delete the record AND hook into the delete key down event to call a routine that deletes the record. I need to do some post delete re-querying of the form so it updates correctly. OnDelete cannot re- query the form AFTER the delete. How would the application events know which form or report to control? Well, if you used an application level AfterDelete (or any other application level event) it would apply to ALL open forms (etc). I don't understand what a application delete event could do that a form delete event could not do better, unless you are allow users to edit the tables; which is not a best practice in Access. If you need some code to run after any delete, like logging, call a module level function. |
|
With the current event model the form manages the data. Say you have two forms viewing the same table open in two tabs. You type in the first form, tab (click) to the next form. Now try typing data in the second form. You can't. *The data is still locked from the first edit. You must detect (on the de/activate of Each form) when it is de/activated and save the previous record before editing the new form because it won't automatically save. And to save that record we get to the 'dirty=true/false' silliness. And I say it's silly because there is no *form/control level auto-save method. I would think you would want to verify the data before using it in the 2nd form. Just like if a 2nd user wanted to edit the data on that record. Holding the user on the 1st form and showing them an error message would be less confusing then seeing the error from the 1st form displayed in the 2nd. |
|
When you click a tab you get Control, Record and Form events on the form you are leaving and Form, Record and Control events on the form you are entering. Not saying it's completely wrong, I'm just saying it can be more orthogonal AND allow the developer to tap into the higher level event system that is already there, just not exposed to us. You may want to look at object modules. I once saw a example using object modules to control 2 instances of the same form, allowing data to be passed though the object. It was a booking application that allowed you to move customers between 2 open events. |
#8
| ||||
| ||||
|
|
Aha. Now I am forced to make an event for each form. Trying to automate what tab the ribbon moves to based on the access application tab. You don't have write a event for each form, put a function or a sub in a module and call it from the form. Enter "=YourFunctionName()" in the deactivate event . Yes you are right, but that is in effect inserting an event stub in each form/report, even if it is just to call the same routine. The more direct way is to be able to use an application tab event. That way you don't need to remember to insert that de/activate event stub in each new form/report. I will be walking away from this db at some point but the users may still be creating new reports and will have to remember this (arbitrary) formality. Not only a new programmer but also you after a number of years of not working the the application. That is why you document the application and test changes. |
|
Okay, thanks. Access could use a rewrite of it's event system imho. There are no top level application events to tap into, no 'after delete' event, record saves w/ a 'dirty=true', it's all quite ridiculous. What would those events look like? Would you put after delete and record save code in both the form and the application events? I initially intended the form event, but at the application level could be useful as well. At present I create a right-click/context menu to delete the record AND hook into the delete key down event to call a routine that deletes the record. I need to do some post delete re-querying of the form so it updates correctly. OnDelete cannot re- query the form AFTER the delete. How would the application events know which form or report to control? Well, if you used an application level AfterDelete (or any other application level event) it would apply to ALL open forms (etc). I don't understand what a application delete event could do that a form delete event could not do better, unless you are allow users to edit the tables; which is not a best practice in Access. If you need some code to run after any delete, like logging, call a module level function. |
|
With the current event model the form manages the data. Say you have two forms viewing the same table open in two tabs. You type in the first form, tab (click) to the next form. Now try typing data in the second form. You can't. The data is still locked from the first edit. You must detect (on the de/activate of Each form) when it is de/activated and save the previous record before editing the new form because it won't automatically save. And to save that record we get to the 'dirty=true/false' silliness. And I say it's silly because there is no form/control level auto-save method. I would think you would want to verify the data before using it in the 2nd form. Just like if a 2nd user wanted to edit the data on that record. Holding the user on the 1st form and showing them an error message would be less confusing then seeing the error from the 1st form displayed in the 2nd. |
|
When you click a tab you get Control, Record and Form events on the form you are leaving and Form, Record and Control events on the form you are entering. Not saying it's completely wrong, I'm just saying it can be more orthogonal AND allow the developer to tap into the higher level event system that is already there, just not exposed to us. You may want to look at object modules. I once saw a example using object modules to control 2 instances of the same form, allowing data to be passed though the object. It was a booking application that allowed you to move customers between 2 open events. |
![]() |
| Thread Tools | |
| Display Modes | |
| |