Closing a form through on exit field event

  • Thread starter Cyberwolf via AccessMonster.com
  • Start date
C

Cyberwolf via AccessMonster.com

I have a form that I want to close based on whether a field has certain info
and an action taken by the user. I keep gEtting an error 2585. I have tried
several suggestions found on this board including opening another form and
closing the form from the other on open event but I still get the Error 2585.

Here is the relevant code

Private Sub Rules_Table_Type_Exit(Cancel As Integer)
 
J

John W. Vinson

I have a form that I want to close based on whether a field has certain info
and an action taken by the user. I keep gEtting an error 2585. I have tried
several suggestions found on this board including opening another form and
closing the form from the other on open event but I still get the Error 2585.

Well... the Exit event is too hair-trigger. It will fire even if the user
simply clicks into the control, does nothing, and clicks out - or even just
tabs through it. If you want the code to run when the user has made a
SELECTION in the combo, use the AfterUpdate event instead.

I'm not certain about the colons in form names. Is your form actually *named*
frm:AltSwitchboard, or is it AltSwitchboard? If you're going to use special
characters in form names, I'd suggest consistantly putting the names in
[square brackets] just to prevent confusion.
 
C

Cyberwolf via AccessMonster.com

Yes my form is actually named frm:AltSwitchboard. Legacy database, that
would require a boatload of code changes to fix. I will remember the brackets
in the future. I don't want to use the AfterUpdate event, because most times
this field does not need to be updated. The field is pre-populated so the
AfterUpdate doesn't fire. How about if I populate the BeforeUpdate event
that just copies itself into itself? Would that then fire the AfterUpdate?
I have a form that I want to close based on whether a field has certain info
and an action taken by the user. I keep gEtting an error 2585. I have tried
several suggestions found on this board including opening another form and
closing the form from the other on open event but I still get the Error 2585.

Well... the Exit event is too hair-trigger. It will fire even if the user
simply clicks into the control, does nothing, and clicks out - or even just
tabs through it. If you want the code to run when the user has made a
SELECTION in the combo, use the AfterUpdate event instead.

I'm not certain about the colons in form names. Is your form actually *named*
frm:AltSwitchboard, or is it AltSwitchboard? If you're going to use special
characters in form names, I'd suggest consistantly putting the names in
[square brackets] just to prevent confusion.
Here is the relevant code
[quoted text clipped - 21 lines]
Any help would b e greatly appreciated.
 
J

John W. Vinson

Yes my form is actually named frm:AltSwitchboard. Legacy database, that
would require a boatload of code changes to fix. I will remember the brackets
in the future. I don't want to use the AfterUpdate event, because most times
this field does not need to be updated. The field is pre-populated so the
AfterUpdate doesn't fire. How about if I populate the BeforeUpdate event
that just copies itself into itself? Would that then fire the AfterUpdate?

Well, I don't know! Under what circumstances do you want the code to run? If
the AfterUpdate event won't fire, how can you be sure that the Exit event will
fire either - the user might never set focus to the control, after all!
 
C

Cyberwolf via AccessMonster.com

You have a good point. It might make sense to re-evaluate pre-populating
that field if they have not chosen a "Table" name from the list-box on the
original form. This way they are forced to enter something into this field
and therefore triggering the AfterUpdate event. I can then validate the text
typed in on the BeforeUpdate to make sure it falls in the list of allowable
characters.

Thanks John, you gave me some great food for thought.
 
J

John W. Vinson

You have a good point. It might make sense to re-evaluate pre-populating
that field if they have not chosen a "Table" name from the list-box on the
original form. This way they are forced to enter something into this field
and therefore triggering the AfterUpdate event. I can then validate the text
typed in on the BeforeUpdate to make sure it falls in the list of allowable
characters.

I'd actually go a step further. If there is a list of allowable entries, give
the poor user a combo box to SELECT one of them, rather than making them type
blindly into a textbox and then slapping their hand if they type wrong!
 
C

Cyberwolf via AccessMonster.com

Acutally my input form that I open via acdialog has a list-box, But I am
building in functionality for adding a new entry. This is based on a
combination of 2 fields the Rules_Table_Name field and the Rules_Table_Type
field. I then do a DCOUNT on a query that uses the forms fields as the
criteria. I have reprogrammed so that if no entry is selected for the
Rules_Table_Name then they are required to fill in both fields manually and
if there is no matching records, they are asked if they want to add a new
record in which case I have a series of other forms that are opened via
acDialog (modally?) to capture pertinant data on the new entry. I am wokring
with a legacy database that unfortunately was not structured very well. It
also is used to feed information to an AS400 application that is a flat db.
So there is a lot of redundent information. I am slowly working towards a
better design, but managment is bulking at it. (don't fix what ain't broke!!!
)

Thanks for all your help.
 

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

Top