Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

finding a name on list

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sam - 13 Apr 2005 21:01 GMT
i have a form with a list of customers
for finding a name on the list user write's the name in a text box
the code i'm using is:
Private Sub TextBox_KeyUp(KeyCode As Integer, Shift As Integer)
   Recalc
   Screen.ActiveControl.OnKeyUp = ""
   SendKeys "{F2}", True  'Press F2 (Goto end of text line)
   TextBox.OnKeyUp = "[Event Procedure]" 'Restore Event
'
   Me.RecordsetClone.FindFirst "left([CustomerName]," & Len(TextBox) & ")
= '" & Me!TextBox & "'"
   Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

while user write's the last name it's working ok
but when entering space between last name and first name, space disapears
and name can't be found

have an idea?

thanks
sam
John Webb - 13 Apr 2005 21:10 GMT
Afraid I don't know the answer to your query, but I thought I would point
out another possible problem.  What if the persons surname is something
like O'Shea.

Try the following code, should correct your problem and make sure names
with apostrophes don't mess you about:

***CODE BEGINS***

Dim strSQL as string

strSQL = "CustomerName LIKE " & chr(34) &  Me.TextBox & chr(34)
Me.RecordsetClone.FindFirst strSQL

***CODE ENDS***

UNTESTED, but I think it should work

Cheers

John Webb
John Webb - 13 Apr 2005 21:11 GMT
oops, slight correction:

***CODE BEGINS***

Dim strSQL as string

strSQL = "CustomerName LIKE " & chr(34) &  Me.TextBox & "*" & chr(34)
Me.RecordsetClone.FindFirst strSQL

***CODE ENDS***
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.