Hi everyone
Here, I have a datasheet in split form view and and a search bar that filters the datasheet based on what the user types in. Everything works fine except for one small thing. Whenever the user hits Reset the cursor appears in the agency textbox when it should reappear in the search bar textbox as seen here:
This may present annoyances from a user perspective as they may ending up typing into this textbox when they meant to be typing into the search bar.
Here is the vba for the reset button:
Code:
Option Compare Database
Option Explicit
Private Sub cmdReset_Click()
Me.txtSearch = ""
Me.SrchText = ""
Me.txtSearch.SetFocus
DoCmd.Requery
End Sub
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub SrchText_AfterUpdate()
Me.SrchText.Requery
End Sub
Private Sub txtSearch_Change()
'Create a string (text) variable
Dim vSearchString As String
vSearchString = txtSearch.Text
SrchText.Value = vSearchString
If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
Exit Sub
End If
'Me.SearchResults = Me.SearchResults.ItemData(1)
'Me.SearchResults.SetFocus
DoCmd.Requery
Me.txtSearch.SetFocus
If Not IsNull(Len(Me.txtSearch)) Then
Me.txtSearch.SelStart = Len(Me.txtSearch)
End If
End Sub
I should mention that, whenever I remove the single quotes on lines:
Code:
'Me.SearchResults = Me.SearchResults.ItemData(1)
'Me.SearchResults.SetFocus
I get an Compile Error:
Method or data member not found
Also, here is the SQL in the query:
Code:
SELECT AgencyINFO.Agency, AgencyINFO.Subsidary, AgencyINFO.ProgramCode, AgencyINFO.ProgramNotes, AgencyINFO.Address, AgencyINFO.City, AgencyINFO.Prov, AgencyINFO.PostalCode, AgencyINFO.FirstName, AgencyINFO.LastName, AgencyINFO.ContactNameNotes, AgencyINFO.OriginalEmail, AgencyINFO.newPhoneNumber, AgencyINFO.newPhoneNumberNotes, AgencyINFO.AAStartDate, AgencyINFO.AAFinalDate, AgencyINFO.InsuranceExpiryDate, AgencyINFO.InsuranceExpiryComments, AgencyINFO.WSIBYesNo, AgencyINFO.WSIBNotes
FROM AgencyINFO
WHERE (((AgencyINFO.Agency) Like "*" & Forms!frmNewAgencySearch!SrchText & "*")) Or (((AgencyINFO.Subsidary) Like "*" & Forms!frmNewAgencySearch!SrchText & "*")) Or (((AgencyINFO.ProgramCode) Like "*" & Forms!frmNewAgencySearch!SrchText & "*")) Or (((AgencyINFO.FirstName) Like "*" & Forms!frmNewAgencySearch!SrchText & "*")) Or (((AgencyINFO.LastName) Like "*" & Forms!frmNewAgencySearch!SrchText & "*"));
As always, any thoughts or suggestions are welcomed and much appreciated!
**NOTE: I tried posting this on the access-programmers.co.uk site however, the database seems to have crashed and I am unable to post there. I understand cross-posting is not appreciated but I need assistance with this and if it turns out that my original post on access-programmers is there, then feel free to delete this post. Thank you.