Search form creates an error when I type the first letter as lower case i (1 Viewer)

atrium

Registered User.
Local time
Tomorrow, 05:54
Joined
May 13, 2014
Messages
348
When I type the first letter I into the search text area I get the following error
Run-time error '2110'
Microsoft Access can't move the focus to the control SearchResults

Most of the code is below

QRY-SearchAll
SELECT Clients.ClientId, Clients.ClientFileNumber, Clients.ClientShortFileNo, Clients.Salutation, Clients.FirstName, Clients.LastName, [Group Branches].BranchCode, Clients.Phone, Clients.Mobile, Clients.Fax, Clients.BpayRef, Clients.TradingAs, Clients.EntityType, Clients.ABN, Clients.ACN, Clients.Address1, Clients.Address2, Clients.Town, Clients.State, Clients.PostCode, Clients.Country, Clients.Email, Clients.ClientGroup, Clients.DateCreated, Clients.Notes, Clients.LastModified, Clients.UserCode, Clients.BdmCode, Clients.CollLongNo, Clients.CollShortNo, Clients.BdmReviewDate, Clients.ClientStatus
FROM Clients LEFT JOIN [Group Branches] ON Clients.BranchCode = [Group Branches].BranchId
WHERE (((Clients.ClientFileNumber) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((Clients.FirstName) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((Clients.ClientId) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*"));

Frm_SearchMulti
Private Sub SearchFor_Change()
'Create a string (text) variable
Dim vSearchString As String

'Populate the string variable with the text entered in the Text Box SearchFor
vSearchString = SearchFor.Text

'Pass the value contained in the string variable to the hidden text box SrchText,
'that is used as the sear4ch criteria for the Query QRY_SearchAll
SrchText.Value = vSearchString

'Requery the List Box to show the latest results for the text entered in Text Box SearchFor
Me.SearchResults.Requery


'Tests for a trailing space and exits the sub routine at this point
'so as to preserve the trailing space, which would be lost if focus was shifted from Text Box SearchFor
If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
Exit Sub
End If

'Set the focus on the first item in the list box
Me.SearchResults = Me.SearchResults.ItemData(1)
Me.SearchResults.SetFocus

'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of the List Box
DoCmd.Requery

'Returns the cursor to the end of the text in Text Box SearchFor
Me.SearchFor.SetFocus (This is were the debugger points to for the error)

If Not IsNull(Len(Me.SearchFor)) Then
Me.SearchFor.SelStart = Len(Me.SearchFor)
End If
End Sub

Private Sub SearchResults_Click()
DoCmd.OpenForm "ClientFileFrm", acNormal, , "[Clients.ClientId] = " & Me.SearchResults, acFormEdit
End Sub


This has been bugging me for some time now and any help would be most appreciated.
 

atrium

Registered User.
Local time
Tomorrow, 05:54
Joined
May 13, 2014
Messages
348
I changed the property sheet of the search box. Under the Other tab, there is an option for 'Allow AutoCorrect' changed that to No and it all works now.
Thanks to another forum but I thought I would post it here for others to gain the benefit
 

Users who are viewing this thread

Top Bottom