calculated field and update 
Author Message
 calculated field and update

 I'm using a datagrid to show data from a table that has a date field. I
wanted an extra column on the datagrid to show a character that would
flag Saturdays, Sundays, or both, as a visual aid to seeing the data
grouped in weeks.
 I couldn't find a way to set a datagrid column to some separate value
calculated per record, once the datagrid had its datasource set to the
table.
 The solution I came up with was to modify the query statement to
include a calculated field, like this:

SELECT * , iif ((date mod 7 >-1 and date mod 7 < 2),'?','') AS wknd FROM
Runs

where date is one of the fields included in runs. Then I added a first
column to the datagrid with datafield = "wknd". This works ok, in that
it shows an extra column with a character '?' if the day is Saturday or
Sunday, and nothing if it isn't.

 Fine so far, but then, if I change a field in that recordset, and try
to update it, I get an error message:
"Row cannot be located for updating. Some values may have changed since
it was last read."

 I supposed this was due to the inclusion of a calculated field in the
recordset, and I got around it by doing edits/updates with a second
recordset, which then had to be synchronized to the first recordset.

 Is it correct that a recordset that includes a calculated field can't
be used for edits/updates? If there is a way around it, what is it?

 Does anyone know a way to make a datagrid column show a calculated
value based on its row's contents without making it part of the
recordset?

 Is there some format string that could produce a flag for particular
weekdays in a redundant column set to the field 'date'?

 Thanks for any ideas.

--
john



Thu, 30 Sep 2004 10:12:44 GMT  
 calculated field and update
John

Try MSFLEXGRID. More code but more control.

Sukesh



Thu, 30 Sep 2004 21:27:53 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Updating Calculated field depending on Current Date

2. ADO Update of calculated field

3. How to update calculated fields in SQL query?

4. Using--After Update-- to update field in table.

5. Updating fields: footer doesn't update right

6. 2nd SQL Server update after update text field corrupts row - using RDO

7. Updating data to a memo field using SQL UPDATE

8. How to update datetime field with NULL using ADO update

9. Using Update to update an Access field

10. Use report fields to update table fields

11. single field to multiple field update qry

12. Update a Bound field with data from unbound field

 

 
Powered by phpBB® Forum Software