# OnCellEdit with table name as a variable

**URL:** <https://forum.inductiveautomation.com/t/oncelledit-with-table-name-as-a-variable/34986>\
**Category:** General Discussion\
**Created:** [May 22, 2020, 8:18pm UTC](https://forum.inductiveautomation.com/t/oncelledit-with-table-name-as-a-variable/34986 "2020-05-22T20:18:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RForshey](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@RForshey](https://forum.inductiveautomation.com/u/RForshey)\
**Post date:** [May 22, 2020, 8:18pm UTC](https://forum.inductiveautomation.com/t/oncelledit-with-table-name-as-a-variable/34986/1 "2020-05-22T20:18:58Z")

</div>

Happy Friday! I have an "OnCellEdit script;  
id = self.data.getValueAt(rowIndex, ‘ID’) #Get the id of the database column.  
query = “UPDATE [Quotes\_VE30].[dbo].Q3001312\_Materials SET [%s] = ? WHERE id = ?” % (colName)  
args = [newValue, id]  
system.db.runPrepUpdate(query, args)  
system.db.refresh(self,“data”)  
That works as expected. But, I need to have the table name be a variable. Try as I might, I can’t get anything to work! The “Q3001312” portion of the table name is selected via a drop down box.

Any ideas? and thanks!
