Passing variable in Field Calculator

Discussion created by katronee on Sep 24, 2012
Latest reply on Sep 24, 2012 by jskinner-esristaff
Having problem with syntax trying to pass variable as the result in field calculator.  Looping through raster file, selecting cells of a certain criteria, upon each selection, I am wanting to pass a date (as a text value) to the selected cells.  Can run this manually *i.e. assign a definite value in CalculateField tool programatically  :

gp.CalculateField_management(depth_int_ras, "CAL_DATE", "\"1/7/1985\"", "VB", "")    this works.

But when I try to pass text as variable(i.e. theExpression = "1/7/1985"), I can't get syntax right.

Have tried:
  gp.CalculateField_management(depth_int_ras, "CAL_DATE", "" + str(theExpression), "VB", "") and
  gp.CalculateField_management(depth_int_ras, "CAL_DATE", theExpression, "VB", ""), etc.

P.S. CAL_DATE is a text field and I either get a crash or values of zero on various tries I've had.

Thanks for any assistance,