Hi all
I have a search bar that filters a datasheet on split form view and works very nicely. I made an exact copy of this however, the original form the user can edit and make changes if necessary, this copy will only be used for looking up records AND NOT EDITING. Here's the VBA for the search bar:
Code:
Option Compare Database
Option Explicit
Private Sub cmdReset_Click()
Me.txtSearch = ""
Me.SrchText = ""
DoCmd.Requery
Me.txtSearch.SetFocus
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'm just trying to find the simplest way where users can still use the search bar just not edit anything in the datasheet. I'm pretty sure there is something on the form properties that I can change but I've been messing around with it and so far, I can either not type anything it at all or I can still edit records on this copy. Any thoughts, as always, much appreciated!