FindFirst with numeric field

D

dhstein

For some reason I'm having a lot of problems getting a findfirst to work.
First I tried comparing to a text field but that didn't work. Now I'm trying
to compare to a numeric field (ID) but that's not working either. The first
line is I believe correct for a text field. What is the correct syntax if
the field is numeric? Thanks for any help on this.

rsCategories.FindFirst "ID = '" & Category & "'"


rsCategories.FindFirst "ID = " ????????
 
D

dhstein

Thanks Doug. I still can't get the find to work , that is to find the
record. The record definitely exists. ID is an autonumber field. I'm
testing with a value of 10 which is in the table. The Category variable is
Dimensioned as Integer. I think I'm having some problems with data typing.
Either I get a "not found" condition or a type fields mismatch.
 
J

Jeff Boyce

Any chance you're working with a linked table?

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
D

Dale Fye

since autonumbers are generally long integer, I'd define your Category
variable as long, not Integer.

What is the rest of the code in this sequence?

Are you certain that rsCategories contains the ID field?

I usually use FindFirst with a recordset clone, followed immediately by a
test of no match, something like:

Dim rs as DAO.Recordset

Set rs = rsCategories.recordsetclone
rs.FindFirst "[ID] = " & Category
if rs.nomatch = true then
msgbox "No match was found!"
else
rsCategories.bookmark = rs.bookmark
endif
 

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