vba - DLookup Crosstab Query from Numeric Field Name -




i have crosstab crosstab value numeric field, values of 1, 2, 3, 4, 5.

this results in query field names numeric: i.e. "1", "2", "3", "4", "5".

however, when dlookup on query such as:

x1 = dlookup("1", "aquery", "samplecode ='" & samplecode & "'") x2 = dlookup("2", "aquery", "samplecode ='" & samplecode & "'") x3 = dlookup("3", "aquery", "samplecode ='" & samplecode & "'") x4 = dlookup("4", "aquery", "samplecode ='" & samplecode & "'") x5 = dlookup("5", "aquery", "samplecode ='" & samplecode & "'") 

i returns of 1, 2, 3, 4 , 5 instead of values in fields. happens if this:

x1 = dlookup(1,"aquery",...) 

any ideas? thanks

your dlookup

x1 = dlookup("1", "aquery", "samplecode ='" & samplecode & "'") 

is interpreting you've written command lookup value 1 object aquery. result value provided in first argument.

to avoid ambiguity, specify field names square brackets (still wrap whole thing in quotes can provide dlookup string).

x1 = dlookup("[1]", "aquery", "samplecode ='" & samplecode & "'") 

or better still:

x1 = dlookup("[1]", "aquery", "[samplecode] ='" & [samplecode] & "'") 

the brackets not necessary, including them should never create problem, it's habit when working in access.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -