Error when Filtering

M

McCoy

Recently I posted a question on filtering by fields. I have managed to
work this out,

With Me.Recordset
DoCmd.ApplyFilter , "RecordCode = UserInput"
End With

but now get an error

"Object Invalid or No Lognger Set"

The field 'RecordCode' that im using to search from is the masterfield
for a subform, as a result all the values in the subform contain
"#Name?" instead of their correct values. I assume the subform would
need to relocate its values after the filter has finished with the
'RecordCode' field.

Can anyone offer any solutions.

Thanks in advance

Please post all replies to m.p.a.forms
 
G

Gerald Stanley

If UserInput is a number, try
DoCmd.ApplyFilter , "RecordCode = " & UserInput
otherwise try
DoCmd.ApplyFilter , "RecordCode = '" & UserInput & "'"

Hope This Helps
Gerald Stanley MCSD
 

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