I have a fairly standard recordset that gives a compile error.
No matter how I word the "if" statement I get "Method or data member not found"
I have tried 'rs.fieldname, rs.fields("fieldname"), rs![fieldname]. I have tried all with a "." or a "!" and keep getting the same error.
I have triple checked the spelling of each and every element in the code but continue to get this compile error.
I have also tried dbopensnapshot.
The highlighted section is either ".fields" in "rs.Fields("Infrafamily")"
or ".Infrafamily" in "rs.Infrafamily"
What am I doing wrong??
No matter how I word the "if" statement I get "Method or data member not found"
I have tried 'rs.fieldname, rs.fields("fieldname"), rs![fieldname]. I have tried all with a "." or a "!" and keep getting the same error.
I have triple checked the spelling of each and every element in the code but continue to get this compile error.
I have also tried dbopensnapshot.
The highlighted section is either ".fields" in "rs.Fields("Infrafamily")"
or ".Infrafamily" in "rs.Infrafamily"
What am I doing wrong??
Code:
Public Function LastBox()
Dim rs As Recordset
Dim iVar As String
Dim num As Integer
Dim frm As Form
num = 0
iVar = "Malvaceae"
Set rs = CurrentDb.OpenRecordset("main", dbOpenDynaset) 'dbopensnapshot
rs.MoveFirst
Do
If rs.Fields("Infrafamily") = iVar Or rs.Family = iVar Then
num = IIf(rs.BoxNo > num, rs.BoxNo, num)
End If
rs.MoveNext
Loop While Not rs.EOF
LastBox = num
End Function