If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Form's Last Event
Form's Last Event
Hello, Using Access ’03… I set my form’s record source in the form’s on load event; it’s usually a SQL string. I subsequently set the record source to “” in the form’s unload event (this was suggested in posts I've read). What I’ve described above has worked rather well for me in the past… On my latest form, I have a lot of code in the form’s on current event— code such as setting control property values. When my new form closes, however; I’m getting an error. I understand the error, but I don’t understand why I’m getting it! What appears to be happening is that the form’s on current event is firing after the form’s unload event; i.e., the form’s record source is set to “” (in the form’s unload event) and then values are assigned (in the form’s current event) throwing an error. I don’t understand why the on current event is firing after the form’s unload event. I even tried putting—me.recordsource = “”—in the form’s on close event, but the form’s current event is even firing after that! Maybe this is by design, but I’m wondering where I could stick the code such that it’s the last thing to fire. I “fixed” the error I was getting by using “on error resume next” in the form’s on current event, but I hate to do that. Thanks, alex |
#2
|
|||
|
|||
Form's Last Event
Alex
The Current event can fire for all sorts of reasons. I would just move your recordsource code to the form's Close event. That should be safe and you won't have to resort to a Resume Next. -- Bill Mosca, Microsoft Access MVP http://www.thatlldoit.com "alex" wrote: Form's Last Event Hello, Using Access ’03… I set my form’s record source in the form’s on load event; it’s usually a SQL string. I subsequently set the record source to “” in the form’s unload event (this was suggested in posts I've read). What I’ve described above has worked rather well for me in the past… On my latest form, I have a lot of code in the form’s on current event— code such as setting control property values. When my new form closes, however; I’m getting an error. I understand the error, but I don’t understand why I’m getting it! What appears to be happening is that the form’s on current event is firing after the form’s unload event; i.e., the form’s record source is set to “” (in the form’s unload event) and then values are assigned (in the form’s current event) throwing an error. I don’t understand why the on current event is firing after the form’s unload event. I even tried putting—me.recordsource = “”—in the form’s on close event, but the form’s current event is even firing after that! Maybe this is by design, but I’m wondering where I could stick the code such that it’s the last thing to fire. I “fixed” the error I was getting by using “on error resume next” in the form’s on current event, but I hate to do that. Thanks, alex . |
#3
|
|||
|
|||
Form's Last Event
On Apr 20, 4:46*pm, Bill Mosca
wrote: Alex The Current event can fire for all sorts of reasons. I would just move your recordsource code to the form's Close event. That should be safe and you won't have to resort to a Resume Next. -- Bill Mosca, Microsoft Access MVPhttp://www.thatlldoit.com "alex" wrote: Form's Last Event Hello, Using Access ’03… I set my form’s record source in the form’s on load event; it’s usually a SQL string. I subsequently set the record source to “” in the form’s unload event (this was suggested in posts I've read). What I’ve described above has worked rather well for me in the past… On my latest form, I have a lot of code in the form’s on current event— code such as setting control property values. When my new form closes, however; I’m getting an error. *I understand the error, but I don’t understand why I’m getting it! What appears to be happening is that the form’s on current event is firing after the form’s unload event; i.e., the form’s record source is set to *“” (in the form’s unload event) and then values are assigned (in the form’s current event) throwing an error. *I don’t understand why the on current event is firing after the form’s unload event. *I even tried putting—me.recordsource = “”—in the form’s on close event, but the form’s current event is even firing after that! Maybe this is by design, but I’m wondering where I could stick the code such that it’s the last thing to fire. I “fixed” the error I was getting by using “on error resume next” in the form’s on current event, but I hate to do that. Thanks, alex .- Hide quoted text - - Show quoted text - Hi Bill; thanks for responding. I did move the code to the form's on close event, but the on current event is firing after the on close event! Is the form's on close event the absolute last event that a form would perform? According to my research it is. I don't know what's causing the on current event to fire; I'm thinking it might be one/some of the control's after update events since I'm modifying the recordsource. Thanks, alex |
Thread Tools | |
Display Modes | |
|
|