OnCurrent event in continuous form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

'I have a subform that is a continuous form. I need to set a date when a
drop-down value is changed but I dont want to set the date if the value is
changed and then changed back to the original value. So I only want to do the
check when I move off of the record in the subform. Is there an OnCurrent
event I can use in this case, or is there some other way?
 
You could use the oldvalue property of the control and check to see if the
oldvalue = currentvalue. If so set the date otherwise don't. You could do the
check in the before update

hth
 
That's what I'm doing roght now. But it fires before I move off the record,
so if the user changes the value back I cannot undo the date setting.
 
The only way to know if the record is going to be updated is if the record
is dirty, therefore I would suggest that you use the records before update
event to do this.

I suppose I would also in addition put in a check in case this is a new
record.

try something like

if me.NewRecord = false then
if cboboxName.OldValue <> cboBoxName then
me!MyDateField = date
end if
end if

If the above code does not work, then you might have to resort to actually
saving the value of the combo box at the form's level module code. You would
do this setting via the on current event. However, you would also use the
before update event.

option explicit
dim vComboValue as varient

then, for on-current go

if isnull(me!comboField) = false then
vComboValue = me!ComboField
else
vComboValue = null
end if

And, then for before update, go:

if isnull(vComboValue) = false then
if cboboxName <> vComboValue then
me!MyDateField = date
end if
else
me!MyDateField = date
end if

You could give my first suggested a try. My spider sense seems to tell me
that I had some problems with using "old value" property in the past, I
just can't quite remember off the top of my head what the problem was. I do
remember having some problem, thus why I've given you a second possible
solution also.
 
Back
Top