View Single Post
  #5  
Old December 13th, 2006, 02:25 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default ComboBox is for looking up records

The combo box should be an unbound field used only for searching.

Create a Select statment for the row source property of the combo.
Something like:
SELECT ClientID From ClientTable;

This will give you a drop down list of all the client's in the table.

Now use the combo's After Update event to locate and display the selected
client:

Dim rst As Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "[ClientID] = " & Me.cboClientSearch
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing

That will take care of looking up existing clients. Once you get that
working, you may want to explore how to handle adding new clients when the
client doesn't exist in the table, but get this working, first.

Now, another thing that will probably pop up is that something like ClientID
may not be meaningful to the user - it may even be an Autonumber field. In
this case, you will still need the field to do the search, but you will want
to display the client name. Add the name to the combo's row source query:

SELECT ClientID, ClientName From ClientTable;

Set the following properties of the combo:
Bound Column 1
Column Count 2
Column Width 0";1.5" (This will make the ID invisible and show only the name)

This will not change The After Update event code.

Post back if you have further questions.
"TizTIz" wrote:

I have a form that want to add a combo box that will show my list of clients
(client names located in a table), when you select a client it will show all
records for the particular client.

This is most likely a very simple process, but I'm having a heck of a time
figuring out this out. How would I do this?