Multiple OR's in Select (1 Viewer)

rkapfer

Registered User.
Local time
Today, 03:34
Joined
Jul 26, 2002
Messages
14
I’m trying to conjugate a SELECT using a multiple OR’s in my WHERE clause, with little success.

SELECT [Student Info Table].[StuID], ([Student Info Table].[First Name] & " " & [Student Info Table].[Last Name]) FROM [Student Info Table] WHERE [Forms]!pLName=[Student Info Table].[Parent 1A Last] Or [Forms]![pLName]=[Student Info Table].[Parent 1B Last] Or [Forms]![pLName]=[Student Info Table].[Parent 2A Last] Or [Forms]![pLName]=[Student Info Table].[Parent 2B Last] ORDER BY [Student Info Table].[Last Name];

This statement is my RowSource bound for display in a combo box for selection, I’ve verified pLName has the correct value via On Click/MsgBox.

The intention here is to select only those students who’s Parents last name matchs that of the last name in [Forms]![pLName]. I imagine children from the same family could have different last names via divorce.

When I hit the drop down or run the SELECT in datasheet view I get the same result, nothing.

Thank you in advance!
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 02:34
Joined
Feb 28, 2001
Messages
27,223
Well, for starters, you are using keyword Forms as an actual name in your example. If that is an extract from your database, change the name of the form ASAP. Don't EVER use reserved words as data names in Access.

Next, [Forms] has no valid source in your SELECT statement. If this [Forms] object is supposed to be an open form, you are using the wrong syntax to refer to the controls of the form. If [Forms] is another table, then you have left out a reference to it in the FROM clause.

Which is it?
 

rkapfer

Registered User.
Local time
Today, 03:34
Joined
Jul 26, 2002
Messages
14
No, if my form name is [Inquiries Group] but you made me think, what if I remove the form name and went with just [pLName]? That worked. For some reason if I used [Inquires Group]![pLName] and save the form, the RecordSource is getting changed to [Inquires Group]!pLName=. That didn't work but now that I using just [pLName] it works. Thanks again.
 

Users who are viewing this thread

Top Bottom