473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2751
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,965 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,556 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,556 Expert Mod 16PB
Good to hear you have it sorted anyway :-)
Nov 1 '17 #7

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

Similar topics

3
by: Georges Heinesch | last post by:
Hi. Why is this DAO line producing error 3077 (Syntax error in number in expression)? rst.FindFirst "ValidFrom = " & DateValue(varDate) rst is a defined recordset varDate is a valid date....
4
by: jon.lewis | last post by:
I have a table in Access 97 with a Date/Time type field Formated "Short Date", UK local settings (dd/mm/yy). Want to go to a record with a date selected from a combo (correctly Short Date...
24
by: Salad | last post by:
Every now and then I see ads that state something like "Experience with Large Databases ...multi-gig...blah-de-blah" And I have to laugh. What's the difference between a large or small database? ...
3
by: wvhines | last post by:
Hello: I am an ambitious novice...I have a main form "frmGeneralContracting" that has a subform on it called "frmsubDeliverables" and I am trying to restrict editing if the current user's login...
2
by: JasCot75 | last post by:
Hello all, my first go at this so please be gentle. I'm putting together a simple access database and have run into a problem with date function I found on the web. The code appears to work, but...
25
by: Rick Collard | last post by:
Using DAO 3.6 on an Access 2002 database, I'm getting unexpected results with the FindFirst method. Here's the simple code to test: Public Sub FindIt() Dim db As Database, rs As Recordset...
13
by: ChrisD76 | last post by:
Hi, I am new to using VBA, and have been working with DAO Recordsets. I'm working on a little problem, and think that DAO Recordsets are the solution. I've been playing around with them to try and...
3
by: blur | last post by:
Hi, Good Day! I have a form with a subform and I want to have a line number for each of the records that will be displayed. Here is my setup: I have a table with the field "ID" with the...
4
by: laborimb | last post by:
I want to find and move to a record by giving the project number of a record (in a textfield). When I set a breakpoint to the FindFirst-methodcall everything works fine, the record is found. If I do...
4
by: ConfusedVBA | last post by:
Having trouble with FindFirst method with AND operator. Dim dblADID as Double dim intSID as Integer dim db as Database dim rstE as Recordset set rstE = db.openrecordset("UAInfo",...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.