Which event to use

M

Michalis J.

I have a combo box in a subform depending on the value of which some
textboxes in the subform are hidden and some are visible. When the user
selects a value from the combobox list I need the system to check wheather
the combo already has a value and if this is true I whant to display a
warning message that the value will change.
I am trying to use the BeforeUpdate event of the combo and check if if the
combo value is null but it seems that the combo assumes the value selected
before the event.
Does enybody have an idea on how to do that?
 
P

Paolo

Hi Michalis J.,
To know the value of your combo before the user changed the value you can
use the oldvalue property of the combo in the beforeupdate event i.e.

yourcombo.oldvalue is the value preceding the selection
yourcombo is the value after the selection
So to know if the combo was null
if isnull(yourcombo.oldvalue) then
msgbox "The preceding value was null and the actual value is " & yourcombo
else
msgbox "The preceding value was " & yourcombo.oldvalue & " and the
actual value is " & yourcombo
endif

To use the oldvalue property the combo must be bound to a field in a table.

HTH Paolo
 

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