Array to field names in Query (1 Viewer)

pekajo

Registered User.
Local time
Tomorrow, 00:45
Joined
Jul 25, 2011
Messages
133
I loop thu a table to get field names

myArray(iCounter) = "[" & rstTableName.Fields("DJPR-Import") & "]"

into an array as I need them for a query ie

"SELECT DJPR1." & myArray(0) & ", DJPR1.[READY TIME],...

My issue is that if the field name is one word it works ok however when there are two words it comes thu as 'Expr1: DJPR1.[Ready date]' on the query and does not work.
ReadyDate works
Ready Date does not work.

Any ideas why?
Peter
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:45
Joined
May 7, 2009
Messages
19,175
where are you doing this?
can you show the Code.
it should work (on VBA).
 

pekajo

Registered User.
Local time
Tomorrow, 00:45
Joined
Jul 25, 2011
Messages
133
Hi,

Just solved the issue.
Peter
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:45
Joined
Feb 28, 2001
Messages
27,002
In the absence of proper delimiters or bracketing, SQL sees a space in a field name but thinks it is like an expression with two variables that SHOULD - but does not - have some sort of operator between the variables.

Got to say that I don't think you properly copied your syntax for your loop.

Code:
myArray(iCounter) = "[" & rstTableName.Fields("DJPR-Import") & "]"

That syntax should be more like

Code:
myArray(iCounter) = "[" & rstTableName.Fields(iCounter) & "]"

The syntax YOU gave will either return a field name "DJPR-Import" or it will return nothing.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 13:45
Joined
Jul 9, 2003
Messages
16,245
Just solved the issue.

For the benefit on others reading this and Without an explanation from you, I guess you added field delimiters to your array builder.
 

Users who are viewing this thread

Top Bottom