View Single Post
  #3  
Old May 13th, 2010, 08:11 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Combo box finding wrong record

I'm guessing you have After Update combo box code along the lines of:

Dim rs As Object

Set rs = Me.RecordsetClone
rs.FindFirst "[FirstName] = '" & Me.cboClient & "'"
Me.Bookmark = rs.Bookmark

If so, the FindFirst is producing the results you are seeing. It is finding
the first instance of Robert, no matter who you select. Instead, you could
set up the row source query thus:

SELECT [ClientID], [Surname] & "," & [FirstName] AS FullName
FROM qryClientDetails
ORDER BY [Surname], [FirstName]

Note that it is a two-column query. I am assuming ClientID is unique for
each record, and that it is a number (including autonumber) field. Set the
combo box Bound Column to 1, the Column Count to 2, and the Bound Columns to
something like 0";2".

Your After Update code should be changed to something like:

Dim rs As Object

Set rs = Me.RecordsetClone
rs.FindFirst "[ClientID] = " & Me.cboClient
Me.Bookmark = rs.Bookmark

This finds the first record in which ClientID matches the combo box selection.
Since ClientID is unique, the first matching record is the only one.

You may have something like this for the third line of code:
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

That's OK. I generally do not use "If Not rs.EOF Then", but it does no harm,
AFAIK, and may help in circumstances I have not yet encountered.

KAquestions wrote:
Hi all,

This is driving me nutty! And i know it's probably something really obvious
that i am just not seeing.....

I have a form which has a combo box on it. The combo box has 3 columns,

First Name, Surname, ClientID

(SELECT qryClientDetails.FirstName, qryClientDetails.SurName,
qryClientDetails.ClientID FROM qryClientDetails ORDER BY
qryClientDetails.FirstName

When the bound column is 1, it works, but only up to a point. If there are
two clients called Robert (Robert A and Robert B) and i want Robert B, when
i click on him it always displays the data for Robert A.

When the bound column is 3, it always shows the last record in the table, no
matter what i have selected.

HELP!!

TIA,

Kirst


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201005/1