Synching list with fields

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a form which is bound to a query with some bound controls. On the
same form I also have a list bound to the same query. How can I sync the
controls on the form with the list such that when a list item is selected by
user the controls on the form move to the same record?

Thanks

Regards
 
Hi John,

Access makes it easy for you to do this with the combo box wizard. Just
open your form in design view. Usel the toolbox to put a combo box on your
form. The combo box wizard opens and gives you options. Select the one that
begins with "Find a record on my form . . ."

Another box opens with the field list of your form. Select the Primary Key
Field from the box, and at least one other so you can select the record you
want.

You should have some VBA code in your Combo Box After Update Event that
looks something like this:

Private Sub Combo14_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[CustomerID] = " & Str(Nz(Me![Combo14], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

But all you have to do is click on the combo box, select the record you want
to go to and immediately you are there.

Hope this helps.

Hunter57
Just huntin' for the right data.
http://churchmanagementsoftware.googlepages.com
 
Hi John,

After reading your post again I see I left something out of my reply,

You can use the code from the new combo box's AfterUpdate event, modify it
to match the list item combo box and put the code in that combo box's
AfterUpdate Event.

Hope it helps,
Hunter57
Just huntin' for the right data.
http://churchmanagementsoftware.googlepages.com
 
Did that already but your original hint was very useful. Many thanks.

Regards
 
Private Sub cmbUserinput_AfterUpdate()
if (not isnull(me!cmbUserinput)) then
me.recordsetclone.findfirst "targetfield=" & str(cmbUserinput.Value)
if (not me.recordsetclone.nomatch) then
me.bookmark = me.recordsetclone.bookmark
else
msgbox "No record found..."
end if
end if
end sub

--A--
 

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

Back
Top