469,126 Members | 1,317 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

FindFirst not working

PhilOfWalton
1,430 Expert 1GB
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
  3.  
  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
  12.  
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

Thanks

Phil
Oct 30 '17 #1
6 2410
Luk3r
300 256MB
Phil,
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
2,957 Expert 2GB
Are you getting an error? What happens when "it doesn't work"?
Oct 30 '17 #3
PhilOfWalton
1,430 Expert 1GB
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?

Phil
Oct 30 '17 #4
NeoPa
32,161 Expert Mod 16PB
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
PhilOfWalton
1,430 Expert 1GB
Just to say thanks for your input but the problem turned out to be tables in different databases and Access (or me getting confused)

Phil
Oct 31 '17 #6
NeoPa
32,161 Expert Mod 16PB
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.

Similar topics

3 posts views Thread by Georges Heinesch | last post: by
4 posts views Thread by jon.lewis | last post: by
25 posts views Thread by Rick Collard | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.