[AccessD] Select statement with variable as field name

Kath Pelletti kp at sdsonline.net
Tue May 22 23:10:56 CDT 2007


Thanks Stuart - perfect 

Kath
  ----- Original Message ----- 
  From: Stuart McLachlan 
  To: Access Developers discussion and problem solving 
  Sent: Wednesday, May 23, 2007 1:56 PM
  Subject: Re: [AccessD] Select statement with variable as field name


  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")




   

  -- 
  AccessD mailing list
  AccessD at databaseadvisors.com
  http://databaseadvisors.com/mailman/listinfo/accessd
  Website: http://www.databaseadvisors.com



More information about the AccessD mailing list