I'm pretty new to VBA, i'm trying to fill out a form using information from the most recent date and the next most recent date of a table. I need the name of the table to be a variable, which seems to be causing problems. Right now i have
Dim StudentName As String
MostRecentDate = DMax("TestDate", StudentName)
NextDate = DMax("TestDate", StudentName, "TestDate <> MostRecentDate")
The mostrecentdate works, the second works if the name of the domain is not a variable. There will never be duplicate dates, i'm not worried about it skipping entries with the same date.
Right now, each student has a table with test date rows, and test type columns. I need the dates so i can scan through the table with
With rstStudent
Do Until .EOF
For Each fldTestDate In .Fields
If fldTestDate.Name = "TestDate" Then
If fldTestDate.Value = MostRecentDate Then
'fill form with info from this row
Exit Sub
End If
End If
Next
.MoveNext
Loop
End With
Any ideas?