Searching

Y

Yousoft

Hi, All
I want find or search the vendor name on the list object, by typing or
matching at least 8 letters,
The following code only it is searching by typing the first letter, so I
need some one to help me to find the vendor name while typing full first name
or full name on the list object
Thanks


Private Sub List53_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Vendor] = '" & Me![List53] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
A

Allen Browne

Try code like this:

Private Sub List53_AfterUpdate()
Dim rs As DAO.Recordset
Dim strWhere As String

If Not IsNull(Me.cboMoveTo) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
strWhere = "([Vendor] Like """ & Me![List53] & "*"")"
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub

Explanation of the code:
http://allenbrowne.com/ser-03.html
 
Y

Yousoft

Thanks Mr. Browne, for your reply but this code not working, please try check
it again, specially line no 4 ( I mentioned below)
(If Not IsNull(Me.cboMoveTo) Then))
thanks

Allen Browne said:
Try code like this:

Private Sub List53_AfterUpdate()
Dim rs As DAO.Recordset
Dim strWhere As String

If Not IsNull(Me.cboMoveTo) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
strWhere = "([Vendor] Like """ & Me![List53] & "*"")"
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub

Explanation of the code:
http://allenbrowne.com/ser-03.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Yousoft said:
Hi, All
I want find or search the vendor name on the list object, by typing or
matching at least 8 letters,
The following code only it is searching by typing the first letter, so I
need some one to help me to find the vendor name while typing full first
name
or full name on the list object
Thanks


Private Sub List53_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Vendor] = '" & Me![List53] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
A

Allen Browne

Sorry: cbMoveTo is the name of my combo.
Replace that with the name of your list box, i.e. List53

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Yousoft said:
Thanks Mr. Browne, for your reply but this code not working, please try
check
it again, specially line no 4 ( I mentioned below)
(If Not IsNull(Me.cboMoveTo) Then))
thanks

Allen Browne said:
Try code like this:

Private Sub List53_AfterUpdate()
Dim rs As DAO.Recordset
Dim strWhere As String

If Not IsNull(Me.cboMoveTo) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
strWhere = "([Vendor] Like """ & Me![List53] & "*"")"
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub

Explanation of the code:
http://allenbrowne.com/ser-03.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Yousoft said:
Hi, All
I want find or search the vendor name on the list object, by typing or
matching at least 8 letters,
The following code only it is searching by typing the first letter, so
I
need some one to help me to find the vendor name while typing full
first
name
or full name on the list object
Thanks


Private Sub List53_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Vendor] = '" & Me![List53] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Add if not in combo box 10
Textbox Filter 4
OnLoad event criteria 4
Combo Box Error 3077 - Access 2003 1
RunTime Error 3070 8
Copy Record Button Function 1
Error 2147352567 2
recordset.clone 13

Top