Hi everyone
So I'm working on an access database and I've saved two copies. One is read-only, the other is the copy I've been working on. They're both on the same drive, just in separate folders. I know this should be split, but for the time being I just copied this database for my supervisor to give brief demonstrations. However it was given to my attention that when one user wanted to use it they experienced this error:
Run time error '2185':
You can't reference a property or method for a control unless the control has a focus
And in the debug window this is what appears:
My first thought was that this was an issue with conflicting versions of Access and maybe the user is using an older version. But when I opened up the read-only copy, I got the same error, even though my machine has a newer version of Access. I noticed that when I type really quickly I get this run time error on the read-only version, but whenever I type really fast on my version, I didn't get any errors. Even though the code is nearly identical
The only big difference is that:
'DoCmd.Maximize is commented out on the read-only version. Other than that, the code is identical. Does anyone know why this is? Any feedback, always appreciated!
So I'm working on an access database and I've saved two copies. One is read-only, the other is the copy I've been working on. They're both on the same drive, just in separate folders. I know this should be split, but for the time being I just copied this database for my supervisor to give brief demonstrations. However it was given to my attention that when one user wanted to use it they experienced this error:
Run time error '2185':
You can't reference a property or method for a control unless the control has a focus
And in the debug window this is what appears:
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.Maximize
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
[B]Me.txtSearch.SelStart = Len(Me.txtSearch)[/B][B]//[I]THIS LINE IS HIGHLIGHTED YELLOW[/I][/B]
End If
End Sub
My first thought was that this was an issue with conflicting versions of Access and maybe the user is using an older version. But when I opened up the read-only copy, I got the same error, even though my machine has a newer version of Access. I noticed that when I type really quickly I get this run time error on the read-only version, but whenever I type really fast on my version, I didn't get any errors. Even though the code is nearly identical
The only big difference is that:
Code:
Private Sub Form_Load()
'DoCmd.Maximize
End Sub
'DoCmd.Maximize is commented out on the read-only version. Other than that, the code is identical. Does anyone know why this is? Any feedback, always appreciated!
Last edited: