Results 1 to 4 of 4

Thread: RESOLVED: concatenate sql String

  1. #1

    Thread Starter
    Member Suidae's Avatar
    Join Date
    Nov 2001
    Posts
    52

    RESOLVED: concatenate sql String

    I'm using the following SQL to populate a temporary table. Everything works fine but I would like to have a comma between EmployeeLast and EmployeeFirst. Everything I've tried splits the name into two fields instead of one.


    Code:
    sql = "SELECT tblReportData.EmployeeID AS Employee, Count(tblReportData.EmployeeID) AS Reports, [EmployeeLast]&[Employeefirst] AS Name INTO tbltmpReport "
    sql = sql & "FROM tblEmployee INNER JOIN tblReportData ON tblEmployee.EmployeeID = tblReportData.EmployeeID "
    sql = sql & "WHERE (((tblReportData.DateOpened) Between #" & StartDate & "# And #" & StopDate & "#) AND ((tblReportData.ParentID)=1)) "
    sql = sql & "GROUP BY tblReportData.EmployeeID, [EmployeeLast]&[Employeefirst];"
    Can anyone give me a clue?

    I've have tried and a couple of other combos.

    Code:
    [EmployeeLast]" & " , " & " "[Employeefirst]
    Last edited by Suidae; Aug 20th, 2002 at 03:07 PM.
    I'm a misanthropic philanthropist!
    Frog, the only white meat...

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Try using + instead of &:
    Code:
    sql = "SELECT tblReportData.EmployeeID AS Employee, Count(tblReportData.EmployeeID) AS Reports, [EmployeeLast] + [Employeefirst] AS Name INTO tbltmpReport "
    sql = sql & "FROM tblEmployee INNER JOIN tblReportData ON tblEmployee.EmployeeID = tblReportData.EmployeeID "
    sql = sql & "WHERE (((tblReportData.DateOpened) Between #" & StartDate & "# And #" & StopDate & "#) AND ((tblReportData.ParentID)=1)) "
    sql = sql & "GROUP BY tblReportData.EmployeeID, [EmployeeLast] + [Employeefirst];"
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    Member Suidae's Avatar
    Join Date
    Nov 2001
    Posts
    52
    Thanks for your reply... The result is still
    DoeJohn and I'm trying to have a result of
    Doe, John
    I'm a misanthropic philanthropist!
    Frog, the only white meat...

  4. #4

    Thread Starter
    Member Suidae's Avatar
    Join Date
    Nov 2001
    Posts
    52
    Got it! Just in case anyone wants to know.

    [EmployeeLast] & ', ' & [Employeefirst]
    I'm a misanthropic philanthropist!
    Frog, the only white meat...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width