Results 1 to 4 of 4
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528

    Converting this expression to variable

    Good morning youth
    I have a question
    Can I convert this expression to a variable in the VBA
    In (SELECT [name] FROM [master] As Tmp GROUP BY [name] HAVING Count (*)> 1)
    Thank you


    Az

  2. #2
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528
    Thank teachers
    I mean, how is written in the form of code VBA

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    azhar2006,
    Again we have trouble understanding your intent. Here is one example (air code - untested) of putting sql in a variable.
    I doubt that this is what you are looking for.

    Code:
    'sample showing SQL in MyVariable
    ' Get info about Employees that do NOT have duplicate Name in Table Master
    ....
    Dim myVariable as string
    MyVariable = "In (SELECT [name] FROM [master] As Tmp GROUP BY [name] HAVING Count (*)> 1)"
    Dim mySql as string
    MySql = "SELECT EmployeeID, EmployeeNumber, EmployeeName, EmpEmail FROM MyTable " _
              & "WHERE  EmployeeName "
    Dim db as DAO.Database
    Dim rs  as DAO.Recordset
    Set db = currentdb
    set rs = db.OpenRecordset( MySql & "  NOT " & MyVariable)
    With rs
    Do While not .eof
         Debug.Print !EmployeeID & "  " & !EmployeeNumber & " " & EmployeeName & " " &EmployeeEmail
    .Movenext
    Loop
    End With
    ......

  4. #4
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528
    Hello
    Ha ha
    I am very sorry Orange
    Yes, this is what I want
    Get info about Employees that do NOT have duplicate Name in Table Master
    Thanks again

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

Similar Threads

  1. Replies: 3
    Last Post: 05-28-2013, 12:53 PM
  2. Replies: 2
    Last Post: 03-15-2013, 12:49 PM
  3. Replies: 0
    Last Post: 08-10-2011, 11:59 AM
  4. Replies: 1
    Last Post: 02-03-2011, 07:41 AM
  5. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM

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