Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Concatenation

Status
Not open for further replies.

Rjc8513

Technical User
Feb 12, 2001
140
US
Can someone help me concatenate this one?

I want to combine the fields:
[LAST NAME] & "," & [FIRST NAME]

in a SELECT statement as the field "EMPL NAME".

Can't seem to get it to work. Thanks.

 
Try something like. Although, I don't believe in using spaces in data names.

([LAST NAME] & "[,]" & [FIRST NAME]) as [EMPL NAME]

 
Hi!

If you are in the query design screen then you use:

[Empl Name]: [Last Name] & ", " & [First Name]

hth
Jeff Bridgham
bridgham@purdue.edu
 
If you trying to query a list of names from the employee table, try this.

dim rs as adodb.recordset
dim cn as adodb.connection
set rs = new adodb.recordset
set cn = currentproject.connection

RS.Open "SELECT * FROM EMPLNAME WHERE LASTNAME LIKE '" & TEXT.Value & "%' AND FIRSTNAME LIKE '%" & Text.Value & "%' ORDER BY LNAME,FNAME", CN, adOpenStatic

Hope this helps.
 
The full code is:

dbs.CreateQueryDef "sqry- MPOO EMF QBF by mpoo 2", _
"SELECT [tbl EMF ARCHIVE].[FINANCE NO], [tbl EMF ARCHIVE].[POST OFFICE], " & _
"[tbl EMF ARCHIVE].[YRPP],[tbl EMF ARCHIVE].[WEEK], " & _
"[tbl EMF ARCHIVE].[PAY LOC], [tbl EMF ARCHIVE].[DES ACT], " & _
"[tbl EMF ARCHIVE].[LDC], [tbl EMF ARCHIVE].[SSN], " & _
"[tbl EMF ARCHIVE].[LAST NAME]'" & "', '" & "'[tbl EMF ARCHIVE].[FIRST NAME] AS [EMPL NAME], " & _
"[tbl EMF ARCHIVE].[WKHRS], [tbl EMF ARCHIVE].[OT], " & _
"[tbl EMF ARCHIVE].[POT], [tbl EMF ARCHIVE].[TOTAL], " & _
"[tbl EMF ARCHIVE].[AL], [tbl EMF ARCHIVE].[SL], " & _
"[tbl EMF ARCHIVE].[LWOP], [tbl OFFICE LISTING].[MPOO] " & _

"FROM [tbl EMF ARCHIVE] INNER JOIN [tbl OFFICE LISTING] ON " & _
"[tbl EMF ARCHIVE].[FINANCE NO]=[tbl OFFICE LISTING].[FINANCE NO] " & _

"GROUP BY [tbl EMF ARCHIVE].[FINANCE NO], [tbl EMF ARCHIVE].[POST OFFICE], " & _
"[tbl EMF ARCHIVE].[YRPP],[tbl EMF ARCHIVE].[WEEK], " & _
"[tbl EMF ARCHIVE].[PAY LOC], [tbl EMF ARCHIVE].[DES ACT], " & _
"[tbl EMF ARCHIVE].[LDC], [tbl EMF ARCHIVE].[SSN], " & _
"[tbl EMF ARCHIVE].[LAST NAME],[tbl EMF ARCHIVE].[FIRST NAME], " & _
"[tbl EMF ARCHIVE].[WKHRS], [tbl EMF ARCHIVE].[OT], " & _
"[tbl EMF ARCHIVE].[POT], [tbl EMF ARCHIVE].[TOTAL], " & _
"[tbl EMF ARCHIVE].[AL], [tbl EMF ARCHIVE].[SL], " & _
"[tbl EMF ARCHIVE].[LWOP], [tbl OFFICE LISTING].[MPOO] " & _

"HAVING ((([tbl OFFICE LISTING].[MPOO])=Left([Forms].[frm MPOO EMF QBF].[cbxSEARCH],1))) " & _

"ORDER BY [tbl EMF ARCHIVE].[FINANCE NO], [tbl EMF ARCHIVE].[YRPP], " & _
"[tbl EMF ARCHIVE].[WEEK], [tbl EMF ARCHIVE].[PAY LOC], " & _
"[tbl EMF ARCHIVE].[DES ACT],[tbl EMF ARCHIVE].[LDC],[tbl EMF ARCHIVE].[SSN];"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top