Problem with combobox search on form. Works great until ..

SomeGuy

Registered User.
Local time
Today, 18:49
Joined
Sep 26, 2000
Messages
62
I have a combo box which searches for the names of an associate (co-worker) and then pulls up the record. The info for the combobox comes from a query of the original associates table because I wanted to concatenate the names which are entered seperately in the table( in other words, there is a seperate field for the first and last names and I want them like the following: ie. Jones, Tom E. )

The search WORKS GREAT until you enter a name that is not on the list and then it will say that the name is not in the list so you need to select one. If you then pick a name, it works fine. If you don't (by removing the previously typed name), it gives a run time 3077 (missing operator error)

Oh, also, just in case it was the cause of my problem, I tried to change the limit to list property but it will not let me change the selection from yes to no because, as it puts it, "The first visible column, which is determined by the columnwidths property, isn't equal to the bound column. Adjust the column width property first, and then set the LimitToWidth property"

Since the link is being done with the AssociateID (shown below) but I want the list to show the concatenated name, the AssociateID column width was set to zero inches and hence the bound columns becomes 1 instead of 2.

I don't know if this is related to my problem but.......

What am I doing wrong?
Any help would be appreciated.

The following is the code that is used for the combo box:

Private Sub FindRecord_AfterUpdate()
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[AssociateID] = " & Me![FindRecord]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

Here is the row source for the combo box (there are two fields used in the query AssociateID and FullName) :

SELECT DISTINCTROW [Qy: AssociatesName].[AssociateID], [Qy: AssociatesName].[FullName] FROM [Qy: AssociatesName];
 
Found an answer in another forum. All I had to do is add an If IsNull statement. I'll leave this post here in case others need help with this problem.

Private Sub FindRecord_AfterUpdate()
If IsNull(Me.ActiveControl) Then Exit Sub ' Exit code if Null
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[AssociateID] = " & Me![FindRecord]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
 

Users who are viewing this thread

Back
Top Bottom