I am trying to pull data from an access database based on the user logged in. I have set a variable for the column name, but of course when I plug this in to my SQL statement it views it as variable instead of a column name...imagine that. Here is the statement.
SQLName = "SELECT Name FROM tblNames Where '" & User & "' <> '" & ID & "' ORDER BY Name"
The '"&ID&"' is what I want to be the column name (example of column name is UserID1 - UserID16). Is there anyway to do this? Say something like "If ID = Column UserID 10 Then the SQL statement could use the column number instead of the name. Does this make sense. In other words, can I tell the SQL statement to compare X against Column Number instead of the actual Column Name?
Thanks,
Paul
SQLName = "SELECT Name FROM tblNames Where '" & User & "' <> '" & ID & "' ORDER BY Name"
The '"&ID&"' is what I want to be the column name (example of column name is UserID1 - UserID16). Is there anyway to do this? Say something like "If ID = Column UserID 10 Then the SQL statement could use the column number instead of the name. Does this make sense. In other words, can I tell the SQL statement to compare X against Column Number instead of the actual Column Name?
Thanks,
Paul