change control to combo box?

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

Guest

I have a form with several subforms. The control on the main form currently
displays the chosen record, and I have buttons next to it to scroll to the
"previous" or "next" record. To make it easier for users, I'd like to change
this to a drop-down (combo box) so it is faster to select the appropriate
record. I tried using the wizard to add a new combo box into the main form,
but when a new record is selected, none of the records in the subforms
change. It doesn't seem to recognize the relationships.

I feel it must have something to do with the RowSource Property or maybe a
Parent/Child link, but I have never had to make a switch like this. Can
anyone help give me some direction to make this switch?

Any help is greatly appreciated!
 
Kevin,

The combo box should be unbound with a rowsource that includes your record
identifier field (e.g. KeyValue). I can't remember the exact code off the top
of my head, but you need to program the After Update event for the combo box.
Assuming you're using DAO it goes something like:

Private Sub Combo1_AfterUpdate()

Me.RecordsetClone.FindFirst "KeyValue = " & Combo1
'Or if your key field is text
'Me.RecordsetClone.FindFirst "KeyValue = '" & Combo1 & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

You will also need to program the On Current event for the form to
synchronise the contents of the combo when you move to a new record:

Private Sub Form_Current

Combo1 = KeyValue
'Assuming you have a (hidden) control showing this value

End Sub

Hope this helps,

Jon.
 
Back
Top