I have several forms hierarchycaly nested in each other
(form/subform/subform/subform....).
The final form is "continous form", while parent forms are single forms
through which navigation was performed by navigation buttons.
Now I want to enable navigation through records both by navigation buttons
and COMBOBOXES. Therefore I added comboboxes besides textboxes.
Let's suppose that txtAAA is textbox and cbxAAA is cmbobox. My aproach was
following:
' Events on the form:
' 1. On Load event fills combobox with the first value
Private Sub Form_Load()
cbxAAA = cbxAAA.ItemData (0)
End Sub
' 2. On Current event synchronizes combobox value with current record in the
form (represented by txtAAA)
Private Sub Form_Current()
Me.cbxAAA.Reque ry
For i = 0 To cbxAAA.ListCoun t
If cbxAAA.ItemData (i) = Me.txtAAA Then
Me.cbxAAA = cbxAAA.ItemData (i)
Exit For
End If
Next i
End Sub
' On the COMBOBOX istelf we have After Update event which synchronizes
current record (txtAAA)
' with the value selected from the combobox.
Private Sub cbxAAA_AfterUpd ate()
With CodeContextObje ct
DoCmd.GoToContr ol "txtAAA"
DoCmd.FindRecor d .cbxAAA, acEntire, False, , False, acCurrent, True
End With
End Sub
This works perfectly as long as both textbox and combobox are visible. But,
my intenion was to hide textbox.
Unfportunately, when I put property txtAAA.Visible= False, the above
mentioned After Update event generates an error, because Find method
requires an object focus and hidden object can't have focus...
What is the alternative solution ?
Thanks.
Comment