I have this database where I need to check if the membership is expiring next month. The field is a 4 character text field mmyy. I have code to reverse the comparison data to yymm to make it easier to compare and to account for going from December to January:
If Format(Now(), "mm") = 12 Then
NextMonthYear = Format(Now(), "yy") + 1 & "01"
Else: NextMonthYear = Format(Now(), "yy") & Format(Now(), "mm") + 1 'reversed for comparison
End If
strSQL = NormalSelect & ", [Expiration] FROM Table1 " & _
"WHERE [Life] <> Yes " & _
" AND (Right([Expiration],2) & (Left([Expiration],2) <= " & NextMonthYear & _
" ORDER BY [Last]"
CurrentDb.QueryDefs("Membership Expiring Next Month").SQL = strSQL
DoCmd.OpenQuery "Membership Expiring Next Month"
I know the [Life] <> Yes is working but this portion:
" AND (Right([Expiration],2) & (Left([Expiration],2) <= " & NextMonthYear & _
is giving me an error at runtime.
Any help is appreciated.
Thanks,
Ric
I suggest you use built in date arithmetic.
No need for NextMonthYear
Just use Format(DateAdd("m",1,date(
Compare that
...AND clng([Expiration]) <= clng(Format(DateAdd("m",1,
Regards,
Bill