OpenForm with acDialog, can a return value be set?

G

Guest

I'm using the "NotInList" event to open a form in Dialog mode ... is there
some elegant way to pass a value back to the originating code so I know what
the user decided to do?

I'm creating a pedigree database for dogs ... when I'm adding a record to
the Dogs table, one of the fields is the father of the dog, which of course
is just another record in the Dogs table ... when the user hasn't entered the
parents info yet I want to open another copy of the same form using the
NotInList event ... I confirm with the user that it is not a typo and they do
want to enter another dog record ... I then open up a copy of the original
form using the OpenArgs to pass along the name and gender of the parent dog
.... the user then fills out the form and at the bottom can either "Save" or
"Cancel" ... if they Save then I want to set the Response to acDataErrAdded,
if however they decide to Cancel then I should set the Response to
acDataErrContinue. By opening the form in Dialog mode the code in the
original form is suspended until the second copy of the form is closed, but
when it is closed I don't know what the user decided to do.

strTempAddDog = "Sire" & "/+/" & strTempName
DoCmd.OpenForm "frmDogsCreateDialog", acNormal, , , , acDialog, strTempAddDog

Is there some way of passing a value back to this point in the code so I can
then appropriately set the Response value to my NotInList event;

Private Sub Sire_NotInList(NewData As String, Response As Integer)

Any help would be appreciated.
 
A

Allen Browne

For this particular case, it probably doesn't matter, i.e. if the NewData
was not added to the table, Access will trigger the error anyway before the
user can get out of the combo.

If you prefer, you could set a public variable in the AfterUpdate event of
the dialog form, and test and reset it in the NotInList event.
 
G

Guest

Thanks Albert, that helps ... the subtile difference between a form being
hidden or closed ...
 
G

Guest

Thanks for the reply Allen ... in my case the second form does indeed add the
value back into the table that the combo box is based on ... if the user
selects Save in the dialog form ... actually what I really want to have is
two types of Save ... a Save/Return, a Save/Continue and a Cancel ...
Albert's suggestion about hidding the form versus closing it I think is the
answer ... I can include some hidden Toggles on the form which will get set
depending on what the user select ... then I make the entire form hidden
which returns processing to the originating form so I can check the states of
the Toggle buttons and determine what the user chose.

Thanks again.
 

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