Search Form Run-time 2448 error

G

Guest

All the searchs work except the search for the Denial Details I have the main
search form that pulls off the main Denials table, this form has a subform in
the footer that opens a datasheet view of the search results. Within that
subform is another subform for the Denial Details of reasons for denials.

In the main search form I have an unbound combo box that lists the reasons
for denials. When I hit the search button I continue to get a Run-time 2448,
Can't assign value to this object.

I am really doing alot of learning of this as I go along. Below is part of
the code.

Private Sub Search_Click()
Dim strWhere As String
' If Reasons
If Not IsNull(Reasons) Then
' Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "Denial Details.Reasons Like '*" &
Me.Reasons & "*'"
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Browse Denials", acFormDS, , strWhere, acFormEdit,
acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Denials.Form.Filter = strWhere
Me.Browse_All_Denials.Form.FilterOn = True
End If
End Sub
 
G

Gary Miller

Kat,

When you get an unhandled runtime error like that click on
the Debug button instead of the End button and it will take
you to the offending line of code so you can see where the
error is and try and figure out what about it is causing the
problem. You will need to reset the code manually from the
Run menu in the code window afterwards.

I do see a couple of things that are problematic:

You are creating (Dim) the strWhere variable which gives it
a null value until you give it one. The next line it is used
in says strWhere = strWhere and the next word you join it
too is AND, so in reality it is saying...

Nothing + "AND Reasons Like *Reason*"

You really don't want the AND here. It should just be saying
"Reasons Like *Reason*

You are trying to catch an error (always a good idea) but
that should be done through a proper 'On Error' error
handler (see help) bracketing the code. If the error had
happened where you are checking, it already would have
bombed on you. FYI - Errors generate long integers so your
'strError' string would have had problems. You would have
also needed to DIM strError.

You are probably aware of this, but your Docmd.OpenForm line
is commented out with the apostrophe at the beginning of the
line.

Hang in there. :) This is all part of the learning process.
 
G

Guest

Thanks for suggestions Gary,

I am getting the error on line
Me.Browse_All_Denials.Form.Filter = strWhere

Going to keep playing with it.
 
G

Gary Miller

Kat,

This points to the probablility that the strWhere is not
being put together totally correctly. Here is a trick for
you. Before the line that the code is bombing on, put in
this line...

msgbox strWhere

This will display a message box that will show your filter
string as it has been constructed through your code so far.
Very often the problem will be pretty apparent there. You
could always post this result if you are still having
trouble seeing the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top