Variable field names?

S

Stapes

Hi

I am trying to execute the following code: -

strSQL = strSQL & Nz([" & strCOM_Year & "], 0)

where strCOM_Year is a string I want the system to use as a field
name. It doesn't like this. Keeps saying 'can't find the field "|"
referred to in you expression', even though I can clearly see in the
debug window that the current value of strCOM_Year is "2006/2007".
i.e. I am looking for the value in the field called 2006/2007.

Any ideas?

Stapes
 
R

Rick Brandt

Stapes said:
Hi

I am trying to execute the following code: -

strSQL = strSQL & Nz([" & strCOM_Year & "], 0)

where strCOM_Year is a string I want the system to use as a field
name. It doesn't like this. Keeps saying 'can't find the field "|"
referred to in you expression', even though I can clearly see in the
debug window that the current value of strCOM_Year is "2006/2007".
i.e. I am looking for the value in the field called 2006/2007.

Any ideas?

Stapes

You're missing some quotes...

strSQL = strSQL & "Nz([" & strCOM_Year & "], 0)"
 
S

Stapes

Hi

I am trying to execute the following code: -

strSQL = strSQL & Nz([" & strCOM_Year & "], 0)

where strCOM_Year is a string I want the system to use as a field
name. It doesn't like this. Keeps saying 'can't find the field "|"
referred to in you expression', even though I can clearly see in the
debug window that the current value of strCOM_Year is "2006/2007".
i.e. I am looking for the value in the field called 2006/2007.

Any ideas?

Stapes

Hey

The index shows a reply to this by Rick Brandt - but I can't see it!!!

What's happening?

Stapes
 
D

Douglas J. Steele

Stapes said:
Hi

I am trying to execute the following code: -

strSQL = strSQL & Nz([" & strCOM_Year & "], 0)

where strCOM_Year is a string I want the system to use as a field
name. It doesn't like this. Keeps saying 'can't find the field "|"
referred to in you expression', even though I can clearly see in the
debug window that the current value of strCOM_Year is "2006/2007".
i.e. I am looking for the value in the field called 2006/2007.

Any ideas?

Stapes

Hey

The index shows a reply to this by Rick Brandt - but I can't see it!!!

Rick's reply was:

You're missing some quotes...

strSQL = strSQL & "Nz([" & strCOM_Year & "], 0)"
 
Top