Let's say the criteria line of your query looks something like your example:
Code:
Select *
From dbo.Table
Where dbo.Table.UniqueID = XXXXX
If you were to create this code in VBA, it would look like:
Code:
Dim mySQL as String
mySQL = "Select * From dbo.Table Where dbo.Table.UniqueID = XXXXX"
But you want this UniqueID to be variable, based on what you enter into your Selection Form. So, let's say that you have a text box named "txtID" on your Selection Form, where you input the name you want the query to return. So, in the VBA code that is building your SQL string, when you come to building this criteria part, you incorporate the value from your text box into the code, i.e.
Code:
Dim mySQL as String
mySQL = "Select * From dbo.Table Where dbo.Table.UniqueID = " & Me!txtID
If you want to see if you have the syntax all correct, an easy way to check is after you create the string, return it in a Message Box, i.e.
Then, once you see you have the syntax correct, you assign it to your pre-existing pass-through query using QueryDefs like I did in the link, and then do whatever you want from there (i.e. open the query, open a report or form based on the query, etc).