Combo problems

ian_ok

Registered User.
Local time
Today, 14:41
Joined
May 1, 2001
Messages
90
I have a combo to search for a surname, yet I have a few householders who have the same surname and first name, so if you click on the first one it comes onto the form, yet if you then click on the other one nothing happens....

What is going wrong?

My row source is:
SELECT DISTINCTROW [2001 2002 REGISTRATIONS].Surname, [2001 2002 REGISTRATIONS].[First Name], [2001 2002 REGISTRATIONS].[Landlords address] FROM [2001 2002 REGISTRATIONS] ORDER BY [2001 2002 REGISTRATIONS].Surname;

My after event is:
Sub Combo89_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Surname] = """ & Me![Combo89] & """"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub


Thanks

Ian
 
You need to use an ID field in your rowsource so each row will be unique.
Have this as the first bound column and have it hidden.

HTH
 
Thanks Kevin.

Of course, it makes sence doesn't it. Will try tomorrow (fingers crossed)

Ian
 
Hey, try this out. The code works great for me

Sub ComboBox_AfterUpdate()
' Find the record that matches the control.
Me.Recordset.FindFirst "[ID] = " & Me![ComboBox]
Me.Bookmark = Me.Recordset.Bookmark
End Sub

Good Luck,
Michael

[This message has been edited by MHadden (edited 06-29-2001).]

[This message has been edited by MHadden (edited 06-30-2001).]
 
I encounter the same problem.
I have a table to keep clients general details, in which clientID is primary key(autonumber). In another table Sales Order, I want to use combo box to select client to enter ordering details. Since there is possibility of two persons have same names (incl surname and fist name), I design a combo box of ClientID as SELECT DISTINCTROW [QrySalesOrder].[LastName], [QrySalesOrder].[FirstName], [QrySalesOrder].[NI No] FROM [QrySalesOrder]; these four fields can identify a client sufficiently.
But the combo just can display one field-ClientID. (ClientID is important, I used it to link other forms). But I think name is more meaningful for user. I design another text box [ClientName] which can display the [LastName]+[FirstName] automatically after I select ClientID. According to Micheal's suggestion,I know I should write code in AfterUpdate Event in ComboClientID.

Sub ComboClientID_AfterUpdate ()
'Find the record that matches the control
Me.Recordset.FindFirst"[ClientID]="&Me![ComboClientID]
Me.Bookmark=Me.RecordSet.Bookmark

I don't know what Record Source should I put in the text box [ClientName]? Is the code correct? Please help me out!!
 
u can make ur combo box show other columns by setting the COLUMN COUNT to the no. of desired columns. u can also adjust the widths using the COLUMN WIDTHS and the over-all width by LIST WIDTH.

using this you can display the name and hide the id from the list of the combo box but then again retain the BOUND COLUMN id as value.
 

Users who are viewing this thread

Back
Top Bottom