HEEELP!!! - strWhere Problem with DoCmd.OpenReport
This should be very simple, but I can't make it work.
I'm trying to open a report from a form using DoCmd.OpenReport and two criteria (choosing records that have student names that match two possibilities).
It works with one criteria, as follows:
Dim strWhere as String
strWhere = "[Student] = '" & Me.StudentName1 & "'"
DoCmd.OpenReport stDocName, acPreview, , strWhere
The above seems to work perfectly fine.
However, when I try to go to two criteria, I get errors. For example, the following does not work:
Dim strWhere1 as String
Dim strWhere2 as String
strWhere1 = "[Student] = '" & Me.StudentName1 & "'"
strWhere2 = strWhere1 & " And [Student] = '" & Me.StudentName2 & "'"
DoCmd. OpenReport stDocName, acPreview, , strWhere2
The above does not work. I've tried changing it a bunch of different ways, based on dozens of examples I got off the Internet, but nothing works.
I'm pretty new to VBA. Does anyone know what I'm doing wrong?