J
Jeremy Gollehon
I'm not sure if I can adequately articulate this problem, but here goes.
I have code that changes the RecordSource a form on the fly based on what's
typed into txtFilter.
It looks something like this:
---------------------------------------------------------------
Me.txtCursorHider.SetFocus
Me.RecordSource = ReplaceWhereClause(Me.RecordSource, NewWhereClause)
Me.txtFilter.SetFocus
Me.txtFilter.Text = Nz(sFilterText, "")
Me.txtFilter.SelStart = Len(Nz(sFilterText, ""))
---------------------------------------------------------------
There's obviously more going on in the code but this is the root of the
problem. The code runs perfectly if the RecordSet returned by the new
RecordSouce is not empty. If it's empty (returns no records) then the code
pukes on the line Me.txtFilter = Nz(sFilterText, "") with a run-time error
424, "Object Required".
I know I can get around this like:
---------------------------------------------------------------
If Me.RecordsetClone.RecordCount <> 0 Then
Me.txtFilter.SetFocus
Me.txtFilter.Text = Nz(sFilterText, "")
Me.txtFilter.SelStart = Len(Nz(sFilterText, ""))
End If
---------------------------------------------------------------
But the problem presents itself again in another place in my app where that
solution isn't very useful.
Can someone set some light on why the .Text property of a textbox can't be
set if there aren't any records in the recordset of the form. Is it that
focus isn't truely being set (again when there aren't any records in the
recordset).
Any help in understanding what's going on here and why would be greatly
appreciated.
Thanks for your help!
-Jeremy
I have code that changes the RecordSource a form on the fly based on what's
typed into txtFilter.
It looks something like this:
---------------------------------------------------------------
Me.txtCursorHider.SetFocus
Me.RecordSource = ReplaceWhereClause(Me.RecordSource, NewWhereClause)
Me.txtFilter.SetFocus
Me.txtFilter.Text = Nz(sFilterText, "")
Me.txtFilter.SelStart = Len(Nz(sFilterText, ""))
---------------------------------------------------------------
There's obviously more going on in the code but this is the root of the
problem. The code runs perfectly if the RecordSet returned by the new
RecordSouce is not empty. If it's empty (returns no records) then the code
pukes on the line Me.txtFilter = Nz(sFilterText, "") with a run-time error
424, "Object Required".
I know I can get around this like:
---------------------------------------------------------------
If Me.RecordsetClone.RecordCount <> 0 Then
Me.txtFilter.SetFocus
Me.txtFilter.Text = Nz(sFilterText, "")
Me.txtFilter.SelStart = Len(Nz(sFilterText, ""))
End If
---------------------------------------------------------------
But the problem presents itself again in another place in my app where that
solution isn't very useful.
Can someone set some light on why the .Text property of a textbox can't be
set if there aren't any records in the recordset of the form. Is it that
focus isn't truely being set (again when there aren't any records in the
recordset).
Any help in understanding what's going on here and why would be greatly
appreciated.
Thanks for your help!
-Jeremy