rst.nomatch always returns TRUE

João serras-pereira
João serras-pereira used Ask the Experts™
on
I had this question after viewing type mismatch on rst.findfirst.
On my app, I have a rst with a value and I am always getting a .nomatch situation in spite of the record being there (a match occurs)

van anyone help?



Screen-Shot-2017-10-27-at-12.41.28.png

Screen-Shot-2017-10-27-at-12.41.28.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016

Commented:
Compare it value with true or false..

IF _rst.NoMatch  = True
...
Else
...
End IF
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
Adjust your filter:

strLocateSelected = "CodMilitante = '" & qryMMRfilterNew_rst!CodMilitante.Value & "' And refSelecaoMaster = '" & Me!frmfld_refSelecao.Value & "'"

Open in new window

/gustav
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
You should not have to test for "=True" because the NoMatch property returns a boolean and should not need an "=True" test.

The first thing I would do is print out the criteria string you are using for the FindFirst method; do this right after setting your strLocateSelected value.

debug.print strLocateSelected

Then I would create a query that uses the query you are using for your recordset as its source and add the criteria that was printed in the previous step to the query, to determine whether it actually returns a record.

If not, then rs.nomatch is working properly.
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Hi (Gustav)
Now I am getting a novel error:

Screen-Shot-2017-10-27-at-13.47.05.png
Screen-Shot-2017-10-27-at-13.48.18.png
Top Expert 2014

Commented:
in the Immediate window, use "?" instead of "debug.print"
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
Commented:
that particular error explicitly indicates that the [CodMilitante] field does not exist in the recordset that you are using the FindFirst method against.
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
Yes, that field is missing or misspelled, either in your recordset or in the query.

/gustav
righto and thanks!!!!! I had a misspeleld nam as welll... THANKS for helping mme!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial