473,383 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

possibly a strange request for help

Hi, I'm trying to create a field based on the concatenation of one field but
in different records (which can be grouped together)

an example may help!

id date info
1 3 middle
1 2 first
1 4 last
2 2 left
2 3 right

ok, so I want to create a field 'special' like this (in a different table if
that matters)

id special
1 first middle last
2 left right

so the info field is concatenated (based on date too, just to make life that
more difficult) into 'special'

Is this possible? I have a background in programming so could probably throw
some VB together to sort this, but it would be a whole lot simpler if
someone could advise on a bit of SQL to acheive the same result.

Many thanks,
Chris
Nov 12 '05 #1
4 1093
AFAIK, there is no way to do this with SQL.
VB Coding would be the way.

HTH
- Turtle

"Not Me" <No****@faker.fake.fa.ke> wrote in message
news:bv**********@ucsnew1.ncl.ac.uk...
Hi, I'm trying to create a field based on the concatenation of one field but in different records (which can be grouped together)

an example may help!

id date info
1 3 middle
1 2 first
1 4 last
2 2 left
2 3 right

ok, so I want to create a field 'special' like this (in a different table if that matters)

id special
1 first middle last
2 left right

so the info field is concatenated (based on date too, just to make life that more difficult) into 'special'

Is this possible? I have a background in programming so could probably throw some VB together to sort this, but it would be a whole lot simpler if
someone could advise on a bit of SQL to acheive the same result.

Many thanks,
Chris

Nov 12 '05 #2
DFS
Not Me,

There's a very good chance you CAN do it in SQL, and easily, but I need a
better example of the output you want, using real dates and real values in
the info column.
"Not Me" <No****@faker.fake.fa.ke> wrote in message
news:bv**********@ucsnew1.ncl.ac.uk...
Hi, I'm trying to create a field based on the concatenation of one field but in different records (which can be grouped together)

an example may help!

id date info
1 3 middle
1 2 first
1 4 last
2 2 left
2 3 right

ok, so I want to create a field 'special' like this (in a different table if that matters)

id special
1 first middle last
2 left right

so the info field is concatenated (based on date too, just to make life that more difficult) into 'special'

Is this possible? I have a background in programming so could probably throw some VB together to sort this, but it would be a whole lot simpler if
someone could advise on a bit of SQL to acheive the same result.

Many thanks,
Chris

Nov 12 '05 #3
Not Me wrote:
Hi, I'm trying to create a field based on the concatenation of one field but
in different records (which can be grouped together)

an example may help!

id date info
1 3 middle
1 2 first
1 4 last
2 2 left
2 3 right

ok, so I want to create a field 'special' like this (in a different table if
that matters)

id special
1 first middle last
2 left right

so the info field is concatenated (based on date too, just to make life that
more difficult) into 'special'

Is this possible? I have a background in programming so could probably throw
some VB together to sort this, but it would be a whole lot simpler if
someone could advise on a bit of SQL to acheive the same result.

Many thanks,
Chris


First, create a function. Let's assume the table with the current data is
called Table1, and uses your field names.

Function ConCatString(lngID As Long) As String
Dim strSQL As String
Dim rst As DAO.Recordset

strSQL = "Select Info From Table1 Where ID = " & lngID & _
" And Table1.Info is not null Order By ID, Date"
Set rst = Currentdb.Openrecordset(strSQL,dbopensnapshot)
rst.MoveFirst
If rst.RecordCount > 0 then
Do while not rst.EOF
If Not IsNull rst!Info then _
ConCatString = ConCatString & rst!Info & space(1)
rst.MoveNext
Loop
Endif
rst.Close
set rst = Nothing
End Function

In the query builder, make this an expression. Ex: Name colon Value where
colon is a :
FullInfo : ConCatString([id])

This will return the full info string to the query. It excludes all records
where Info is blank (Null).
Nov 12 '05 #4
"Not Me" <No****@faker.fake.fa.ke> wrote in message
news:bv**********@ucsnew1.ncl.ac.uk...
Hi, I'm trying to create a field based on the concatenation of one field but in different records (which can be grouped together)


Thanks to all for their help - I've got it sorted now :)

Cheers,
Chris
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: leegold2 | last post by:
How do I use rawurlencode()? A snippet would extremely appreciated. I read I should use it twice for plus signs(?) - I need help! Thanks. Very strange stuff happens when I use GET to pass a...
4
by: Max | last post by:
Hello. This is the first time I've posted to a newsgroup, and I do this because I'm in desperate need of help. I'm working a user management system, and when I activate a user that has registered...
13
by: Gary | last post by:
I am trying to do a simple "less than" conditional statement, and hitting a brick wall if I use a database element with it. This DOES work: <% if Request.QueryString("PC") < 10 then...
4
by: Gav | last post by:
Hi all, I'm having this strange problem where, in a web app, I have 2 different links to a different form. One is just a straight forward link the other is a bit more complicated because it gets...
1
by: davidw | last post by:
I encountered strange issues. I have code like this sqlReader = SqlHelper.ExecuteReader(connString, System.Data.CommandType.Text,sql); It calls Microsoft.ApplicationBlocks.Data to execute a...
0
by: Mark | last post by:
Hi - I have a really strange problem - straight forward login code (on the event of a button press). Works perfectly locally - but when I upload to my host, I get the message and stack shown...
16
by: Victor | last post by:
I have a strange problem in my website. I configured my website to run under 2 worker processes. (web garden enabled). and I stored my user information in the current httpcontext(like...
1
by: jbitz | last post by:
Hi, This has got me really baffled. This has got me really baffled. When I run Dim url As String = HttpContext.Current.Request.Url.AbsolutePath.ToLower from Application_beginRequest in...
4
by: David | last post by:
I'm using the AxSHDocVw.WebBrowser control to download data from a webpage at work (it's an internal page on my company's intranet). The page produces a runtime error after a while and the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.