An Access 2002 application I've been asked to look at has a form with a table as the Record Source. On the form is an unbound text box named txtLookup used to allow the user to enter a customer's name to search for. The user can enter the name one character at a time and a second unbound text box named 1stClient will display the list of names that match the characters entered so far. When the user enters a "J", the second text box displays every name starting with "J." When he next types an "o" the second text box displays all names starting with "Jo" and so forth. If the user has typed in "Jones" then all the customers whose last name is Jones display in the second text box.
The code behind the On Change event of the first text box is as follows:
Private Sub txtLookup_Change()
Dim MySql As String
txtFirstName.SetFocus
txtlookup.SetFocus
txtlookup.SelStart = 100
MySql = "SELECT tblClient.pkClient, [Last Name] & ', ' & [First Name] AS Name, tblClient.[Last Name] " & _
"FROM tblClient " & _
"WHERE (((tblClient.[Last Name]) Like '" & txtlookup & "*')) " & _
"ORDER BY [First Name];"
lstClient.RowSource = MySql
End Sub
txtFirstName is the name of a bound field on the form for the first (not last) name.
When the user sees the name he wants to select in the second text box named 1stClient, he can click on the name and the record with that last name will be displayed on the form. The code in the AfterUpdate event of the 1stClient textbox is as follows:
Private Sub lstClient_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[pkClient] = " & Str(Nz(Me![lstClient], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Now here is the problem. At times when the user enters the name to search for in the first text box the system takes maybe 20 - 40 seconds to display each successive letter keyed in. E.g., the user types Jones. The txtLookup text box displays the "J," then "thinks" (searches) for 30 seconds, then displays the "o" and thinks another 30 seconds, then displays the "n" and so on. Normally, the name in txtLookup displays about as fast as the user types and the list of names displayed in the second text box 1stClent displays in less than a second. The first time the user does this search, it seems to work at normal speed. But after updating a bound field on the form and then going back to the txtLookup text box to look for another customer, the system dramatically slows down.
The application has the tables linked to a backend Access database on another user's machine in a peer to peer connection. There are three machines that use the same backend database; each of these machines has the identical frontend database on its C drive. (A typical Access database setup).
Can anyone give me some ideas as to why the display of the letters in the name is soooo slow? I've seen something very similar occur in another environment where the backend is on a server and the frontend is on the users' C drive and there is a domain set up. In this other environment, there is no second text box displaying the list, but rather the list is displayed in the first text box. Yet, the same problem with slowness occurs.
Any help will be much appreciated!
The code behind the On Change event of the first text box is as follows:
Private Sub txtLookup_Change()
Dim MySql As String
txtFirstName.SetFocus
txtlookup.SetFocus
txtlookup.SelStart = 100
MySql = "SELECT tblClient.pkClient, [Last Name] & ', ' & [First Name] AS Name, tblClient.[Last Name] " & _
"FROM tblClient " & _
"WHERE (((tblClient.[Last Name]) Like '" & txtlookup & "*')) " & _
"ORDER BY [First Name];"
lstClient.RowSource = MySql
End Sub
txtFirstName is the name of a bound field on the form for the first (not last) name.
When the user sees the name he wants to select in the second text box named 1stClient, he can click on the name and the record with that last name will be displayed on the form. The code in the AfterUpdate event of the 1stClient textbox is as follows:
Private Sub lstClient_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[pkClient] = " & Str(Nz(Me![lstClient], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
Now here is the problem. At times when the user enters the name to search for in the first text box the system takes maybe 20 - 40 seconds to display each successive letter keyed in. E.g., the user types Jones. The txtLookup text box displays the "J," then "thinks" (searches) for 30 seconds, then displays the "o" and thinks another 30 seconds, then displays the "n" and so on. Normally, the name in txtLookup displays about as fast as the user types and the list of names displayed in the second text box 1stClent displays in less than a second. The first time the user does this search, it seems to work at normal speed. But after updating a bound field on the form and then going back to the txtLookup text box to look for another customer, the system dramatically slows down.
The application has the tables linked to a backend Access database on another user's machine in a peer to peer connection. There are three machines that use the same backend database; each of these machines has the identical frontend database on its C drive. (A typical Access database setup).
Can anyone give me some ideas as to why the display of the letters in the name is soooo slow? I've seen something very similar occur in another environment where the backend is on a server and the frontend is on the users' C drive and there is a domain set up. In this other environment, there is no second text box displaying the list, but rather the list is displayed in the first text box. Yet, the same problem with slowness occurs.
Any help will be much appreciated!