combobox and textbox synchronization

Z

Zlatko Matiæ

Hello.

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.Requery

For i = 0 To cbxAAA.ListCount
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_AfterUpdate()

With CodeContextObject
DoCmd.GoToControl "txtAAA"
DoCmd.FindRecord .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.
 

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