K
KevinC
I'm working on an existing Access 2000 database which the client will not
upgrade to 2002.
I'm having serious problems with a form I want the user to search a table
with.
I have a continuous form with an unbound combo box with the field names I
want to search on and an unbound text box for the search text in the form
header.
I have the following code in the textbox change event.
Private Sub txtSearch_Change()
Me.RecordSource = strQry & cboField & " LIKE '" & txtSearch.Text & "*'
ORDER BY " & cboField
Me.Requery
If Me.RecordsetClone.RecordCount <> 1 Then
Me.txtSearch.SetFocus
Me.txtSearch.SelStart = Len(Me.txtSearch.Text)
End If
End Sub
on the line - Me.RecordSource = strQry & cboField & " LIKE '" &
txtSearch.Text & "*' ORDER BY " & cboField
the txtSearch.Text is causing the following error
Run Time Error 2185
You can't reference a property or method for a control unless the control
has the focus.
Putting txtSearch.SetFocus before the line does not cure it.
Using just txtSearch rather than txtSearch.Text works but causes an the same
error on the line - Me.txtSearch.SelStart = Len(Me.txtSearch.Text)
And only searches on the preceding keypress ie:- entering 'wa' will only
result in - LIKE w* - in the SQL string. Then Pressing backspace and
deleting the 'a' and it will result in - LIKE wa* - in the SQL string.
Is this an undocumented feature in Access 2000 i usually work in VB.
upgrade to 2002.
I'm having serious problems with a form I want the user to search a table
with.
I have a continuous form with an unbound combo box with the field names I
want to search on and an unbound text box for the search text in the form
header.
I have the following code in the textbox change event.
Private Sub txtSearch_Change()
Me.RecordSource = strQry & cboField & " LIKE '" & txtSearch.Text & "*'
ORDER BY " & cboField
Me.Requery
If Me.RecordsetClone.RecordCount <> 1 Then
Me.txtSearch.SetFocus
Me.txtSearch.SelStart = Len(Me.txtSearch.Text)
End If
End Sub
on the line - Me.RecordSource = strQry & cboField & " LIKE '" &
txtSearch.Text & "*' ORDER BY " & cboField
the txtSearch.Text is causing the following error
Run Time Error 2185
You can't reference a property or method for a control unless the control
has the focus.
Putting txtSearch.SetFocus before the line does not cure it.
Using just txtSearch rather than txtSearch.Text works but causes an the same
error on the line - Me.txtSearch.SelStart = Len(Me.txtSearch.Text)
And only searches on the preceding keypress ie:- entering 'wa' will only
result in - LIKE w* - in the SQL string. Then Pressing backspace and
deleting the 'a' and it will result in - LIKE wa* - in the SQL string.
Is this an undocumented feature in Access 2000 i usually work in VB.