FindFirst

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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)
 
Back
Top