E
Elizabeth- MDC
Here's the code:
Public Function Points_Formula(CustomerID As Long, StoreID As Long, Dollars
As Long) As Integer
Dim AddPoints As QueryDef
Dim db As Database
Dim CurrentRules As Recordset
Set db = CurrentDb
Set CurrentRules = db.OpenRecordset("SELECT [RuleID], [RuleName],
[PointperDollar], [PointLimit], [StoreSpecific], " & _
"[StoreID], [StartDate], [EndDate] FROM Rules " & _
"WHERE ([StartDate] <= #" & Date & "# AND [EndDate] >= #" & Date & "# AND
([StoreSpecific] = False OR [StoreID] = " & StoreID & "));")
With CurrentRules
.MoveLast
.MoveFirst
Do While Not .EOF
MsgBox !RuleName
.MoveNext
Loop
.Close
End With
End Function
I know it's sloppy, I'm just trying to figure the basics out. I get the
error at .MoveFirst. If I remove that line, I get the same error at
..MoveNext.
No spaces in names of fields. Table only has two rows in it. It works if
the second row is filtered out by the StartDate and/or EndDate.
Public Function Points_Formula(CustomerID As Long, StoreID As Long, Dollars
As Long) As Integer
Dim AddPoints As QueryDef
Dim db As Database
Dim CurrentRules As Recordset
Set db = CurrentDb
Set CurrentRules = db.OpenRecordset("SELECT [RuleID], [RuleName],
[PointperDollar], [PointLimit], [StoreSpecific], " & _
"[StoreID], [StartDate], [EndDate] FROM Rules " & _
"WHERE ([StartDate] <= #" & Date & "# AND [EndDate] >= #" & Date & "# AND
([StoreSpecific] = False OR [StoreID] = " & StoreID & "));")
With CurrentRules
.MoveLast
.MoveFirst
Do While Not .EOF
MsgBox !RuleName
.MoveNext
Loop
.Close
End With
End Function
I know it's sloppy, I'm just trying to figure the basics out. I get the
error at .MoveFirst. If I remove that line, I get the same error at
..MoveNext.
No spaces in names of fields. Table only has two rows in it. It works if
the second row is filtered out by the StartDate and/or EndDate.