A
Arvi Laanemets
Hi
On some form I have several unbound combobox controls. Whenever some of them
is changed, I want:
1. reset the values for other combos on same form;
2. reset Filter and FilterOn properties for subform on same form;
3. reset Rowsource for a record locating combobox on this subform.
Currently I use combo's AfterUpdate's events for this - like here:
Private Sub Combo1_AfterUpdate()
Me.Combo2 = 0
Me.Combo3 = 0
If Nz(Me.Combo1, 0) = 0 Then
Me.MySubform.Form.Filter = ""
Me.MySubform.Form.FilterOn = False
Me.MySubform.Form.SubformCombo.RowSource= "SELECT MyTable.ID,
MyTable.SomeText FROM MyTable ORDER BY 2;"
Else
Me.MySubform.Form.Filter = "ID1 = " & Me.Combo1
Me.MySubform.Form.FilterOn = True
Me.MySubform.Form.SubformCombo.RowSource = "SELECT MyTable.ID,
MyTable.SomeText FROM MyTable WHERE MyTable.ID1 = " & Me.Combo1 & " ORDER
BY 2;"
' different combos set WHERE condition to different ID-field
here
End If
End Sub
The problem is, those events are fired whenever something on combo is
selected - even when the combos value really remains same.
I want, that event will be fired only, when some combo's value was really
changed, and I can't use OldValue property here, as this works only with
bound controls (for unbound controls it is always same as controls current
value). So I need something along lines:
Private Sub Combo1_AfterUpdate()
If Combo1 was changed Then
' Code above will be inserted here
End If
End Sub
Some ideas anyone?
Thanks in advance!
Arvi Laanemets
On some form I have several unbound combobox controls. Whenever some of them
is changed, I want:
1. reset the values for other combos on same form;
2. reset Filter and FilterOn properties for subform on same form;
3. reset Rowsource for a record locating combobox on this subform.
Currently I use combo's AfterUpdate's events for this - like here:
Private Sub Combo1_AfterUpdate()
Me.Combo2 = 0
Me.Combo3 = 0
If Nz(Me.Combo1, 0) = 0 Then
Me.MySubform.Form.Filter = ""
Me.MySubform.Form.FilterOn = False
Me.MySubform.Form.SubformCombo.RowSource= "SELECT MyTable.ID,
MyTable.SomeText FROM MyTable ORDER BY 2;"
Else
Me.MySubform.Form.Filter = "ID1 = " & Me.Combo1
Me.MySubform.Form.FilterOn = True
Me.MySubform.Form.SubformCombo.RowSource = "SELECT MyTable.ID,
MyTable.SomeText FROM MyTable WHERE MyTable.ID1 = " & Me.Combo1 & " ORDER
BY 2;"
' different combos set WHERE condition to different ID-field
here
End If
End Sub
The problem is, those events are fired whenever something on combo is
selected - even when the combos value really remains same.
I want, that event will be fired only, when some combo's value was really
changed, and I can't use OldValue property here, as this works only with
bound controls (for unbound controls it is always same as controls current
value). So I need something along lines:
Private Sub Combo1_AfterUpdate()
If Combo1 was changed Then
' Code above will be inserted here
End If
End Sub
Some ideas anyone?
Thanks in advance!
Arvi Laanemets