Not in List event and a new form design question

  • Thread starter Corey-g via AccessMonster.com
  • Start date
C

Corey-g via AccessMonster.com

Hi All,

I have a combo box that lists names, and when the not in list event is fired,
I open a form to add all of the required data for that entry. The problem is
that I'm not sure how to handle a user 'cancelling' (or closing) the form
without adding the new data. Originally I didn't have any thoughts about
this, but I realized when I tried to cancel/close without adding the new
entry that it breaks the process. So now I'm trying to figure out the best
way to build this functionality... I thought about using a variable on the
calling form (boolAddedNew) and having this updated from the other form, but
as I debugged it, I got an error that the variable was not defined.

Can I have a variable set from docmd? (boolAddedNew = docmd.open acForm,
"myForm")

Any thoughts would be appreciated,

Corey
 
A

Al Campagna

Corey,
Usually a NotInList is indicated to the user via a MsgBox. "Not in List. Do you want
to add a New record for this entry?"
You should offer the user OK or Cancel on that MsgBox.
User could Cancel back to the original combo entry, or OK go forward to the add record
form.
 
C

Corey-g via AccessMonster.com

Hi Al,

I actually had the same idea, and have implemented a msgbox prompt before
opening the form to add the new record. But this still doesn't handle what
happens if they decide to then close the form without adding the new record.

What I have started and am working through right now is a public variable
that is set when either the cancel button is clicked or the form is closed.
Then the calling form uses this variable to determine if the data was added
and needs to requery, or to have 'response = acdataerrContinue' and return to
the combo box.

Just wanted to see how others handle this...

Thanks for the response,

Corey
 
A

Al Campagna

Corey,
this still doesn't handle what
happens if they decide to then close the form without adding the new record.

Whats happen is that the "add" form never opens... dpending on the user response to
your MsgBox.

Using an IF statement in your code. If the user selects OK, then run the code to open
the "add" form.
But, if they respond with Cancel then bypass the add form opening code.
 

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