Greetings, all.
I hope my subject line is at least somewhat explanatory. I have a query (Query Shipped Today) that returns a single column of data (names of items shipped in a given order). I am attaching a screencap (QueryCap.jpg) of the query.
[FONT="]What I need to have happen is for that column of data to wind up as a single[FONT="] line of text, which [FONT="]is t[FONT="]hen copied to the clipboard. I also need to a) change the name of the header [FONT="]field, and b) add [/FONT]a separator between each item name.
[FONT="][FONT="][FONT="]To illustrate, [FONT="]if[/FONT] my query yields the following column[/FONT][/FONT][/FONT]:
[/FONT][/FONT][/FONT][/FONT]
[FONT="][FONT="][FONT="]Here's [FONT="]how it works: [/FONT][/FONT][/FONT]I have a function which copies the query results[/FONT] to the clipboard[FONT="]:
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]
[FONT="]and then call[FONT="]s a [FONT="]another macro[FONT="]:
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]
[FONT="]Which runs [FONT="]the Word [/FONT]macro[FONT="]:[/FONT][/FONT]
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]
[FONT="][FONT="]The Word macro pastes the [FONT="]contents of the clipboard in[FONT="]to a document (QueryResultCap.jpg) as a tab[FONT="]le. [/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]T[/FONT]he[FONT="] ma[FONT="]cro then removes the first [FONT="]two [FONT="]rows, selects the whole column, cuts it, and pas[FONT="]tes it as plain text. (PlainTextCap).
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]Through [/FONT]a conv[FONT="]oluted series of Find/Replace st[FONT="]atements, the[FONT="] ma[FONT="]cro [FONT="][FONT="]removes the hard returns, adds "Shipped [FONT="]XofX:" to the fron[FONT="]t of the [FONT="]line,[/FONT][/FONT][/FONT] [FONT="]and insert[FONT="]s " | " [FONT="]after eac[FONT="]h item name, [/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]all of which give[FONT="]s me t[FONT="]he [FONT="]result I refer[FONT="]enced [/FONT]a[FONT="]b[FONT="]o[FONT="]ve.[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[FONT="]It [FONT="]then copies that result to the clipboard so it can be pasted w[FONT="]here I need it to go, [FONT="]and closes the Word application.
[FONT="]As I [FONT="]said, it's a work-around.
I'd like to take the [FONT="]Word macro out [FONT="]of this pr[FONT="]ocess[FONT="], but I'm not even remo[FONT="]tely sure [FONT="]this can be do[FONT="]ne entirely in the Access env[FONT="]ironment, and if it can, I[FONT="] don't know where to start. I [FONT="]looked into building [/FONT]a Transpose query base[FONT="]d [FONT="]on my [/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]Query Shipped Today query [/FONT][/FONT], but ev[FONT="]idently you can't do one of those if you have only one column.
[FONT="][FONT="]I also have zero ideas abo[FONT="]ut how I wo[FONT="]uld get those separator[FONT="]s in th[FONT="]eir, even if I could have made the Transpose que[FONT="]r[FONT="]y work.
[FONT="]Is ther[FONT="]e any hope here, or is [FONT="]what I [FONT="]want just not po[FONT="]ssible within the confines of [FONT="]Access?
[FONT="][FONT="]As always, any light that can be shed in[FONT="]to the m[FONT="]urky swamp of my Access [FONT="]knowledge will be appreciated![/FONT][/FONT][/FONT][/FONT][/FONT]
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
I hope my subject line is at least somewhat explanatory. I have a query (Query Shipped Today) that returns a single column of data (names of items shipped in a given order). I am attaching a screencap (QueryCap.jpg) of the query.
[FONT="]What I need to have happen is for that column of data to wind up as a single[FONT="] line of text, which [FONT="]is t[FONT="]hen copied to the clipboard. I also need to a) change the name of the header [FONT="]field, and b) add [/FONT]a separator between each item name.
[FONT="][FONT="][FONT="]To illustrate, [FONT="]if[/FONT] my query yields the following column[/FONT][/FONT][/FONT]:
[/FONT][/FONT][/FONT][/FONT]
[FONT="][FONT="][FONT="][FONT="] [FONT="]Product (header)[/FONT][/FONT][/FONT][/FONT][/FONT]
Backtrack (item #1)
Emelie (item #2)
Krampus (item #3)
Scherzo Diabolico (item #4)
Trouble Every Day (items #5)
I need to get it the following configuration:Backtrack (item #1)
Emelie (item #2)
Krampus (item #3)
Scherzo Diabolico (item #4)
Trouble Every Day (items #5)
Shipped XofX: Backtrack | Emelie | Krampus | Scherzo Diabolico | Trouble Every Day |
[FONT="][FONT="][FONT="][FONT="][FONT="]I have a workaround which involves [FONT="]using [/FONT]a macro [FONT="]in a MS Word docum[FONT="]ent on my workstation, but [FONT="]the process runs a bit slowly (and sometimes crashes my Access application), and[FONT="] I [FONT="]have discovered that it d[FONT="]oesn't [FONT="]work w[FONT="]hen I am working via a certain service that [FONT="]r[FONT="]hymes with MoDoNyDC.
[FONT="][FONT="][FONT="]Here's [FONT="]how it works: [/FONT][/FONT][/FONT]I have a function which copies the query results[/FONT] to the clipboard[FONT="]:
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
Code:
RunCommand acCmdSelectAllRecords
RunCommand acCmdCopy
DoCmd.Close acQuery ("Query Shipped Today")
[FONT="]and then call[FONT="]s a [FONT="]another macro[FONT="]:
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
Code:
Call RunCleanShipped_Word
[FONT="]Which runs [FONT="]the Word [/FONT]macro[FONT="]:[/FONT][/FONT]
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
Code:
Sub RunCleanShipped_Word()
Dim myWD As Object
Dim myFile As Object
Set myWD = CreateObject("Word.Application")
Set myFile = myWD.Documents.Open("C:\Users\g.birkholz\Cleanshipped.docx")
myWD.Run "CleanShipped"
myFile.Close
myWD.Quit
Set myFile = Nothing
Set myWD = Nothing
End Sub
[FONT="][FONT="]The Word macro pastes the [FONT="]contents of the clipboard in[FONT="]to a document (QueryResultCap.jpg) as a tab[FONT="]le. [/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]T[/FONT]he[FONT="] ma[FONT="]cro then removes the first [FONT="]two [FONT="]rows, selects the whole column, cuts it, and pas[FONT="]tes it as plain text. (PlainTextCap).
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]Through [/FONT]a conv[FONT="]oluted series of Find/Replace st[FONT="]atements, the[FONT="] ma[FONT="]cro [FONT="][FONT="]removes the hard returns, adds "Shipped [FONT="]XofX:" to the fron[FONT="]t of the [FONT="]line,[/FONT][/FONT][/FONT] [FONT="]and insert[FONT="]s " | " [FONT="]after eac[FONT="]h item name, [/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]all of which give[FONT="]s me t[FONT="]he [FONT="]result I refer[FONT="]enced [/FONT]a[FONT="]b[FONT="]o[FONT="]ve.[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]
[FONT="]It [FONT="]then copies that result to the clipboard so it can be pasted w[FONT="]here I need it to go, [FONT="]and closes the Word application.
[FONT="]As I [FONT="]said, it's a work-around.
I'd like to take the [FONT="]Word macro out [FONT="]of this pr[FONT="]ocess[FONT="], but I'm not even remo[FONT="]tely sure [FONT="]this can be do[FONT="]ne entirely in the Access env[FONT="]ironment, and if it can, I[FONT="] don't know where to start. I [FONT="]looked into building [/FONT]a Transpose query base[FONT="]d [FONT="]on my [/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="][FONT="]Query Shipped Today query [/FONT][/FONT], but ev[FONT="]idently you can't do one of those if you have only one column.
[FONT="][FONT="]I also have zero ideas abo[FONT="]ut how I wo[FONT="]uld get those separator[FONT="]s in th[FONT="]eir, even if I could have made the Transpose que[FONT="]r[FONT="]y work.
[FONT="]Is ther[FONT="]e any hope here, or is [FONT="]what I [FONT="]want just not po[FONT="]ssible within the confines of [FONT="]Access?
[FONT="][FONT="]As always, any light that can be shed in[FONT="]to the m[FONT="]urky swamp of my Access [FONT="]knowledge will be appreciated![/FONT][/FONT][/FONT][/FONT][/FONT]
[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT]