Results 1 to 2 of 2
  1. #1
    celtics11 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Posts
    1

    How to use variable in SELECT DISTINCT

    Hello everyone,

    Is it possible to use a variable in the first line of the following code?

    Code:
    SELECT DISTINCT [June-11].[Full Name], [June-11].[Level 8 Name]
    FROM [June-11]
    WHERE ((([June-11].[Level 6 Name])="SMITH, BOB") AND ((Exists (SELECT * FROM [July-11]
         WHERE [June-11].[Full Name] = [July-11].[Full Name]))=False));
    I have a combo box that lists months and I want to be able to choose which month goes in the SELECT DISTINCT line of code. So, where it says [June-11], I would like it to reference my combo box so I can select the month. Hope that makes sense!



    Thanks,
    -PM

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    You would have to do this in Code (and it is not a good thing to have tables like that).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  2. select statement with variable table name
    By dv89k in forum Queries
    Replies: 1
    Last Post: 05-26-2011, 10:54 PM
  3. Replies: 8
    Last Post: 04-21-2011, 05:29 PM
  4. SELECT DISTINCT not working
    By johnmerlino in forum Queries
    Replies: 2
    Last Post: 10-25-2010, 06:48 PM
  5. SELECT INTO variable table name
    By Ian P in forum Queries
    Replies: 2
    Last Post: 05-29-2010, 12:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums