FindFirst

G

Guest

Hi!
I have a file named Costs which has one record containing configuration
fields. One of the fields is [Silver Factor]. I have the following
statements to read the first record which contains the configuration data.

Dim rst As DAO.Recordset
strCriteria = "[Silver Factor] <> 0"
Set rst = CurrentDb.OpenRecordset("Costs")
rst.FindFirst strCriteria

I'm getting and error that this operation is not supported for this type of
object on the FindFirst statement. Please help.
 
A

Allen Browne

If Costs is a table in the same database (not an attached table), Access
will have given you a dbOpenTable recordset. To use FindFirst, you need a
dbOpenDynaset type.

Try:
Set rst = CurrentDb.OpenRecordset("Costs", dbOpenDynaset)

A more efficient solution might be to only open the records you need:
Dim strSql As String
strSql = "SELECT Costs.* FROM Costs WHERE [Silver Factor] <> 0;"
Set rst = CurrentDb.OpenRecordset(strSql)
 

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