|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
Hi there,
I wrote this script for my individual records, which worked perfectly On RecordSave () { var srcBox = Form.boxes("Consign"); if (srcBox) { var srcText = srcBox.content; if (srcText != "") { var tgtBox = Form.boxes("NewCC"); if (tgtBox && tgtBox.content == "") { var allWords = srcText.split("/"); tgtBox.content = allWords[0]; } } } } Problem was we have 58,000 records in the database and I didn't want to have to go into each individual record to update the cost code so I had a go at this (by putting a button on my query screen): function update_onClick() { var crs = Application.activeTextbase.currentRecordset; if ((crs != null) && (crs.RecordCount > 0)) { crs.MoveFirst(); while (crs.EOF == false) { var srcBox = Form.boxes("Consign"); if (srcBox) // be sure there is a box with the given name { var srcText = srcBox.content; if (srcText != "") // proceed only if the first box is nonempty { var tgtBox = Form.boxes("NewCC"); if (tgtBox && tgtBox.content == "") // second box must exist and be empty { var allWords = srcText.split("/"); // allWords is an array of words tgtBox.content = allWords[0]; } } } } { crs.Update(); crs.MoveNext(); } } } Which doesn't work Ax |
|||
|
You can't use Form.boxes("boxname").content in a recordset script. You have to change the actual field contents (using crs.Fields("boxname").Value), not the box contents. There is no box in a recordset script.
There is an example in the DB/TextWorks help at the bottom of the "Recordset Object" topic. |
||||
|
That would explain a lot!
I've looked at the example but it seems very complicated and I'm having problems working out what parts I need. All i need the button to do (when pressed) is open all the records then save them. The form script I have should do the rest. I'm starting to think batch modify may be easier than a script. |
||||
|
Well I'm still trying to work this one out - I hate being beaten!
Still not working and I'm trying a different variation. I just want the records in a database to open and save and then close when you click the button Any ideas anyone? function Update_onClick() { Application.message("Starting batch modify."); var crs = Application.activeTextbase.currentRecordset; var validCt = 0; if ((crs != null) && (crs.RecordCount > 0)) { crs.MoveFirst(); while (crs.EOF == false) { Command.editRecord(); Command.saveRecord(); Command.closeWindow(); crs.Update(); validCt = validCt + 1; crs.MoveNext(); } } Application.message(validCt+" records modified."); } Although it seems to work my other scripts don't i.e. I have an script to auto fill a field when the record has saved but when i run the update (which has Command.save Record) the field isn't automatically filled This message has been edited. Last edited by: AT, |
||||
|
As far as I know, one cannnot combine recordSet scripts and normal scripts (the Command.editRecord stuff) as you're trying to do. If you want to modify field contents using a recordset script, you must do so by modifying the crs.Fields("fieldname").Value.
|
||||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

