[AccessD] Select statement with variable as field name

Kath Pelletti kp at sdsonline.net
Tue May 22 22:47:44 CDT 2007


Can anyone tell me how to do this....

TblSurvey2006 as 50 yes/no fields.

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 ("[surveypersonid]", "tblSurvey2006", "strFieldName = -1")



______________________________________
Kath Pelletti


More information about the AccessD mailing list