The issue here is that there are many "flavours" of Visual Basic, and they aren't interchangeable.
Your application is running in MSAccess, and it will have certain objects, functions, etc, that are specifically applicable to that environment. The Cells
object is something that is specifically applicable to the MS Excel environment and therefore Access VBA has no understanding of what a Cells
object is.
(And the documentation you referred to is regarding the syntax for VB.Net - but the specific topic you were looking at is treated the same in all these different versions of "Visual Basic". But it does appear from that web page that the Then
in an If
statement is an optional keyword in VB.Net, while it is required in VBA, so there's one difference on even such an elementary piece of coding.)
If you change your code from
If CDate(rst(3)) >= Date Then
ElseIf Cells(intFile, "CU") = "0" Then
Sheet1.Rows(r).EntireRow.Delete
to be
If CDate(rst(3)) >= Date And rst(98) <> 0 Then
I believe you will be doing what you set out to do, i.e. exclude all records where the 4th field (3
due to zero-base) is before today and also exclude all records where the 99th field is 0.