Combo Box search

diasflac

Registered User.
Local time
Today, 21:45
Joined
May 13, 2013
Messages
45
I am currently using this code.

Private Sub Combo17_AfterUpdate()
If IsNull(Me!Combo17) Then Exit Sub

With Me.RecordsetClone
.FindFirst "[Supplier Name] = " & Me!Combo17
If Not .NoMatch Then
If Me.Dirty Then Me.Dirty = False
Me.Bookmark = .Bookmark
End If
End With
End Sub

It works on another form exactly the same but doesn't work on any others. Control source either off or on doesn't work. It either doesn't move the record and lets you freely select or it gives this error: "microsoft jet database engine does not recognize as a valid field name or expression".

I don't see why it works on one form and not another! :banghead:
 
What is the RowSource of the combo box.. if it is a Text field you are basing your search, try enclosing them in single quotes..
Code:
.FindFirst "[Supplier Name] = [COLOR=Red][B]'[/B][/COLOR]" & Me!Combo17 [COLOR=Red][B]& "'"[/B]
[/COLOR]
 
What is the RowSource of the combo box.. if it is a Text field you are basing your search, try enclosing them in single quotes..
Code:
.FindFirst "[Supplier Name] = [COLOR=Red][B]'[/B][/COLOR]" & Me!Combo17 [COLOR=Red][B]& "'"[/B]
[/COLOR]

That has now produced a different error, it's still not moving records so I'm now getting the, you're creating duplicate index's in this field error. :confused:
 
That's strange.. How about checking EOF before assigning the bookmark?
Code:
Private Sub Combo17_AfterUpdate()
    If IsNull(Me!Combo17) Then Exit Sub

    With Me.RecordsetClone
        .FindFirst "[Supplier Name] = '" & Me!Combo17 & "'"
        If Not .NoMatch Then
            If Me.Dirty Then Me.Dirty = False
            [B]If Not .EOF[/B] [B]Then[/B] Me.Bookmark = .Bookmark
        End If
    End With
End Sub
What about the RowSource..
 
That's strange.. How about checking EOF before assigning the bookmark?
Code:
Private Sub Combo17_AfterUpdate()
    If IsNull(Me!Combo17) Then Exit Sub

    With Me.RecordsetClone
        .FindFirst "[Supplier Name] = '" & Me!Combo17 & "'"
        If Not .NoMatch Then
            If Me.Dirty Then Me.Dirty = False
            [B]If Not .EOF[/B] [B]Then[/B] Me.Bookmark = .Bookmark
        End If
    End With
End Sub
What about the RowSource..

Nevermind, it's working now, I created a new form from scratch and it works. Same code, no explanation to the difference.

Thanks for your help Paul.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom