By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,122 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,122 IT Pros & Developers. It's quick & easy.

FindFirst not working

Expert 100+
P: 1,430
I have used findfirst for ages without problems

Here is a snippet of code
Expand|Select|Wrap|Line Numbers
  1.                 ' Check if the word has been translated
  2.                 If WordNo = 4 And LanguageID = 2 Then Stop
  4.                 Criteria = "[WordNo] = " & CLng(WordNo) & " AND [LanguageID] = " & CLng(!LanguageID)
  5.                 WordSet.MoveLast
  6.                 WordSet.MoveFirst
  7.                 WordSet.FindFirst Criteria
  8.                 If WordSet.NoMatch Then                                 ' Not yet translated
  9.                     TranslatedWordNotFound = -1
  10.                     GoTo TranslateIt
  11.                 End If
I can see the correct line in the query that this criteria is is searching for.

If the criteria is Word = 2 and Language = 4 it works

I have tried with & without the MoveLast & MoveFirst before applying the Criteria

I have tried with & without square brackets

I have tried with & without CLng

I am at a complete loss. Grateful for a soluion


Oct 30 '17 #1
Share this Question
Share on Google+
6 Replies

P: 299
Have you tried adding single quotes around your values instead of trying to interpret them as integers?

Expand|Select|Wrap|Line Numbers
  1. Criteria = "[WordNo] = '" & WordNo & "' AND [LanguageID] = '" & LanguageID & "'"
Oct 30 '17 #2

Seth Schrock
Expert 2.5K+
P: 2,937
Are you getting an error? What happens when "it doesn't work"?
Oct 30 '17 #3

Expert 100+
P: 1,430
Thanks for coming Back.

Both WordNo & LanguageID are long integers and come straight from the Table TblWords.

Thee is no error, the .FindFirst just doesn't find the record. The .NoMatch is True

The only other thing that might have something to do with it is that
all the tables are linked into the main database, and the routine that throws the error is in a Library database. Perhaps I am seeing the table, but the routine is not. If so, why should it work for some values?

Oct 30 '17 #4

Expert Mod 15k+
P: 31,419
You may be suffering with order of precedence of operators. Don't forget AND is a Boolean operator that acts on numeric values.

Try :
Expand|Select|Wrap|Line Numbers
  1. Criteria = "([WordNo] = " & CLng(WordNo) & ") AND ([LanguageID] = " & CLng(!LanguageID) & ")"
Or make it more readable by using Replace() but the result should be the same.
Oct 31 '17 #5

Expert 100+
P: 1,430
Just to say thanks for your input but the problem turned out to be tables in different databases and Access (or me getting confused)

Oct 31 '17 #6

Expert Mod 15k+
P: 31,419
Good to hear you have it sorted anyway :-)
Nov 1 '17 #7

Post your reply

Sign in to post your reply or Sign up for a free account.