[AccessD] Select statement with variable as field name

Stuart McLachlan stuart at lexacorp.com.pg
Tue May 22 22:56:18 CDT 2007


On 23 May 2007 at 13:47, Kath Pelletti wrote:

> 
> On a form, the user selects 1 of 50 possible fields from a combo
> (cboInterests). When they do that I want to count the no. of records
> in the table where *that field* has been ticked as true. 
> 
> Here is what I have so far which I know is wrong because of
> strFieldName - *do* you use a variable as a field name?? I thought
> using eval might be the answer but no luck with that so far either... 
> 
> Dim intnorecs as integer
> Dim strFieldName as string
> strFieldName  = me.cbointerests

intnorecs = DCount ("*", "tblSurvey2006", strFieldName  &  " = -1")




 




More information about the AccessD mailing list