Findfirst Syntax Question

G

Guest

Hi,

I have an import function that takes a tab delimited file and pulls into an
Access table. From here I need to find and pull out certain information.

I have a recordset that I'll call rstPP and I have already narrowed it down
to the data of interest.

My fields in this recordset are called Field1, Field2 etc.

I need to find the first occurence where Field1 in rstPP contains the string
CNumber . In other words, Field1 = "CNumber"

I tried the following and it didn't work:
Findstring = "CNumber"
rstPP.FindFirst "Field1 = " & Findstring

I also tried this:
rstPP.FindFirst "Field1 = CNumber"

Thanks for any insight you can give.
 
S

SusanV

As you are looking for a string, you need single quotes:

Dim Findstring as String
Findstring = "CNumber"
rstPP.FindFirst "Field1 = '" & Findstring & "'"


Also, if this isn't an exact match, you'll need to add wildcards ( use * for
SQL, or % for ADO)
 
G

Guest

Unfortunately that didn't work.

I'm getting a Runtime Error 2351
Operation is not supported for this type of object.

I'm not sure what I am doing incorrectly. rstPP is a recordset.

Dim dbscurrent As Database
Dim rstPP As Recordset
Set dbscurrent = CurrentDb()
Set rstPP = dbscurrent.OpenRecordset("MatImportData",dbOpenTable)

I tried setting my recordset to a DAO.Recordset and get the same error.
 

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