Futures_Bright
Registered User.
- Local time
- Today, 15:53
- Joined
- Feb 4, 2013
- Messages
- 69
Hi all,
I have a problem that has taken me quite a while to try and understand and how to resolve it... I think I understand what the problem is and have an idea of how to fix it - but since I'm not confident about it and the solution will be a ballache I want to get a second opinion:
The problem:
I have a global function called "Permissions" that runs through the form ensuring the right ones are locked/disabled/invisible depending on the user's level on load for all forms (this function uses Screen.ActiveForm to work out which form it should run the code on and I have .setfocus for each of the forms before calling the function). This has worked really well except I've just noticed it doesn't work on two particular forms. In my database I try and limit the possibility of multiple forms being open except when it is necessary - these two forms are examples where multiple forms can be open.
I have a 'Clauses In Review' form to show any clause that needs to be reviewed and (if one exists) the previous version it has updated. Two buttons to open the 'Review Clause' or 'Previous Review' forms. Unfortunately I've now found out that it runs the 'Permissions' function on the 'Clauses In Review' form in the background even after setting focus to the newly open forms.
My understanding of the problem:
So after a day of trying to fix the code (I tried moving it to 'before update' but this won't work on it's own) and frantic googling, I think the problem is that the 'Clauses In Review' form is still active because it all starts with the docmd.OpenForm command for the buttons. I'm not convinced this is the problem because it works on other forms where I have a button to open another form and then close the current one though (i.e. the only difference is these buttons don't close the current form down, but this should happen after the 'on load' event for the new form opened anyway).
If this sounds likely to be the problem, the only solution I can think is to not use Screen.ActiveForm and instead have it a variable given by every form that calls it up - which will mean changing this on Every form I have!
So does this sound likely to be the cause of the problem or are there other things I should check first? Does anyone have any more 'elegant' solutions for me to try that don't involve a lot of man-hours updating code?
Thanks in advance.
I have a problem that has taken me quite a while to try and understand and how to resolve it... I think I understand what the problem is and have an idea of how to fix it - but since I'm not confident about it and the solution will be a ballache I want to get a second opinion:
The problem:
I have a global function called "Permissions" that runs through the form ensuring the right ones are locked/disabled/invisible depending on the user's level on load for all forms (this function uses Screen.ActiveForm to work out which form it should run the code on and I have .setfocus for each of the forms before calling the function). This has worked really well except I've just noticed it doesn't work on two particular forms. In my database I try and limit the possibility of multiple forms being open except when it is necessary - these two forms are examples where multiple forms can be open.
I have a 'Clauses In Review' form to show any clause that needs to be reviewed and (if one exists) the previous version it has updated. Two buttons to open the 'Review Clause' or 'Previous Review' forms. Unfortunately I've now found out that it runs the 'Permissions' function on the 'Clauses In Review' form in the background even after setting focus to the newly open forms.
My understanding of the problem:
So after a day of trying to fix the code (I tried moving it to 'before update' but this won't work on it's own) and frantic googling, I think the problem is that the 'Clauses In Review' form is still active because it all starts with the docmd.OpenForm command for the buttons. I'm not convinced this is the problem because it works on other forms where I have a button to open another form and then close the current one though (i.e. the only difference is these buttons don't close the current form down, but this should happen after the 'on load' event for the new form opened anyway).
If this sounds likely to be the problem, the only solution I can think is to not use Screen.ActiveForm and instead have it a variable given by every form that calls it up - which will mean changing this on Every form I have!
So does this sound likely to be the cause of the problem or are there other things I should check first? Does anyone have any more 'elegant' solutions for me to try that don't involve a lot of man-hours updating code?
Thanks in advance.