translating a query to vba (1 Viewer)

MilaK

Registered User.
Local time
Today, 07:50
Joined
Feb 9, 2015
Messages
285
Hello,
How to translate the following query to vba so I can use it inside a module to open a recordset.

Code:
SELECT DISTINCT ConcatRelated("id","tbl_citation_symbols","symbol like '*" & [symbol] & "*'") AS Expr1, tbl_citation_symbols.symbol
FROM tbl_citation_symbols;


I have tried:

SQL = "SELECT DISTINCT ConcatRelated(tbl_citation_symbols.id,tbl_citation_symbols,tbl_citation_symbols.symbol like '*' & [symbol] & '*'') AS Expr1, tbl_citation_symbols.symbol FROM tbl_citation_symbols"

thank you,

Mila
 
Last edited:

Minty

AWF VIP
Local time
Today, 14:50
Joined
Jul 26, 2013
Messages
10,355
Does the first one actually work ? It doesn't look right to me.
 

MilaK

Registered User.
Local time
Today, 07:50
Joined
Feb 9, 2015
Messages
285
Yes, the query executes fine inside the query wizard, however, i can't figure out how to write it in vba.
 

plog

Banishment Pending
Local time
Today, 09:50
Joined
May 11, 2011
Messages
11,613
Last edited by MilaK; Today at 08:12 AM.

Minty--you're not going insane. The original code could not have worked. He changed it.

Mila--I would take what is now the first SQL code and replace the double quotes with double double quotes and set it equal to the SQL variable:


SELECT DISTINCT ConcatRelated("id"...
SQL = "SELECT DISTINCT ConcatRelated(""id""..."
 

MilaK

Registered User.
Local time
Today, 07:50
Joined
Feb 9, 2015
Messages
285
@Minty The symbol returns the correct values but Expr1 returns Null value for some reason. Thanks for your help.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:50
Joined
Jul 9, 2003
Messages
16,245
Minty >>> CORRECTLY SAID
Does the first one actually work ? It doesn't look right to me.

You REPLIED
Yes, the query executes fine inside the query wizard, however, i can't figure out how to write it in vba.

You should have pointed out that you had corrected the mistake of leaving off the "FROM Clause" in your SQL statement. I looked at your question earlier and I saw the from clause was missing....
 

MilaK

Registered User.
Local time
Today, 07:50
Joined
Feb 9, 2015
Messages
285
I apologize for not mentioning that I've corrected the original post.
thanks
 

Users who are viewing this thread

Top Bottom