PDA

View Full Version : Update a field during processing a Report


ABC123

Russell Sanderlin Sr
02-13-2005, 07:18 AM
Hello Gang,

I have put this request in before and I am still stumped.

What I want to do is update a DATE field with todays date for a group of records that are requested in a REPORT.

Could someone help me step by step please, hopefully using the Code Editor.

And if the Code Editor is not applicable, another option step by step.

It would be much appreciated.

Thanks for the help - Russell

Tom Cone Jr
02-13-2005, 08:15 AM
Sure.

First, post a sample table and it's dictionaries so we have something to work with. The table should be the one your report layout is based upon. If your report is based on a set of tables we'll need all the tables, all their dictionaries, and the dictionaries for the set.

-- tom

Cheryl Lemire
02-13-2005, 10:04 AM
Place the following code after your report print code.

tbl = table.open("your_table_name")
query.filter = "exact_same_filter_you_used_for_your_report"
query.order = "recno()"
ix = tbl.query_create()
tbl.fetch_first() 'fetch first in filtered list
while .not. tbl.fetch_eof()
tbl.change_begin(.t.)
tbl.your_date_field_name = date()
tbl.change_end(.t.)
tbl.fetch_next()
end while
tbl.close()

CALocklin
02-13-2005, 02:44 PM
I've done as Cheryl suggested many times but I sure wish there was a way to change a field as each record was actually printed (not previewed!) so it would mark what was actually done but not mark those records that were missed because of some printing error.

Tom Cone Jr
02-13-2005, 04:25 PM
Cal, I like Cheryl's code, too. However, as I mentioned in the other Sanderlin thread on this subject, I think it's prudent to query the user with a ui_msg_box() to verify that the report printed ok. If they say no, the script can abort without marking or otherwise modifying the records that were included in the print range.

-- tom

Russell Sanderlin Sr
02-13-2005, 06:05 PM
Thanks Tom,

I still have that info, but have been dealing with some personal issues and have not had time to try anything yet.

I am still not clear in the DESIGN mode where to put your code.

Russell Sanderlin Sr
02-14-2005, 06:05 PM
Hello Cheryl,

Thanks for the info.

Now let me go and find where that should be placed.

Thanks much, Russell