Before Update Question

DBL

Registered User.
Local time
Today, 12:37
Joined
Feb 20, 2002
Messages
659
I have a combo box that allows users to enter new data via the Not In List event. If, however, a user has selected a name from the existing list I want to give them an Are You Sure message before updating the main record but if it's a name they've just added through Not In List then I don't want them to get the Are You Sure message. I thought about collecting the new data in a variable at the NotInList stage - and it is assigning the details to the variable - but by the time the Before Update event kicks in (which runs immediately after the NotInList) the variable is blank.

Any ideas? I'm probably doing the variable wrong.

Thanks

Dawn
 
use the beforeupdate event of the combo box. if they decide they have picked the wrong name then set casncel = vbcancel and exit the beforeupdate event. That will force them to pick an acceptable value before they close the box
 
Yep, that's what I've got happening at the moment. But, if it's an identity they have just added through the NotInList event then I want the before update to run without the Are You Sure prompt - because if they've just added the identity then it has to be the one they want.
 
if IsNull(field) then
msgbox ("Are you sure?", vbokcancel + vbcritical, "Confirmation") = vbcancel then
cancel = true
me.undo
else
...(your other code)

EDIT: Just realized you were not looking for a null value, sorry.
 
I've already got that in place but what I can't do is figure out the difference between the combo box where it has been filled through the NotInList or selected from an existing list. I've tried capturing the NewData info in a variable as it goes through the NotInList event and then doing

If IsNull (NewData) ' in other words it has been selected from the existing list
MsgBox "Is this the data you want...." etc.

But by the time I get to the BeforeUpdate event the NewData variable is empty again.
 
assduming the not in list event fires some code, then set a flag in that. Depends on how you handled the notin list event i think, because often a not in list event can open a form to add multiple values - its not necessarily the name thats added that is required.

anyway, set a flag in your not in list event, and then test and reset the flag in the before update event
 
That's what I'm trying to do and can't get it to work :confused:

Can anyone give me a step by step as to how to create a Flag?

D
 
declare a module variable as

dim newitem as boolean

in the not in list event is fired, if your user adds a new item, set
newitem = false, but if the user adds an item then set

newitem = true

then in the before update event you can have

if newitem=false then (or more correctly if not(newitem) but its the same thing)
if msgbox("do you want etc - your current test)
else
newitem = false 'reset it for next time
end if

I hope that helps
 
Last edited:
Thanks Gemma got it working!
 

Users who are viewing this thread

Back
Top Bottom