|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
I am trying to create a work around for Inmagic's inability to perform left truncation searching without using the ODBC driver.
I am trying to develop a script that will split an alpha-number code (e.g. AAA.00, AAA.01, etc.) we use to identify clients at the period and return the number. On a report I have, I don't want the OO codes to appear. I am using the function onRecordOpen() but it appears it's not possible to omit records using this function. Any other ideas for doing this would be greatly appreciated. Here is my script as it is: function onRecordOpen() { OmitClientCodes(); } function OmitClientCodes() { var strProjectCode = Form.boxes("boxProjectCode").content; var aCodes = strProjectCode.split("."); var codes = aCodes[1]; if (codes == "00") { Application.message("This is a client code. It should be omitted."); Command.omitRecord(); } else { Application.message("This is a project code. It should stay."); } } The messages are just for testing purposes. How else could I omit these records from my report? It can't be done via query I don't believe. |
|||
|
Have you tried, say, running through the current recordset and omitting records that way? The recordset object has an OmitCurrentRecord() method. I haven't tested, but seems to me you'd get better results that way than using onRecordOpen() and Command.omitRecord().
This kind of thing: function OmitCodes() { var crs; var isOmit = false; crs = Application.activeTextbase.currentRecordset; if (crs && crs.RecordCount > 0) { crs.MoveFirst(); while (crs.EOF == false) { isOmit = false; //your code-finding logic here... if (isOmit == true) { crs.OmitCurrentRecord(); } else { crs.MoveNext(); } } } Peter Tyrrell, MLIS Senior Consultant Andornot Consulting Inc. http://www.andornot.com/about/developerblog |
||||
|
Very good idea Peter. Thank you. I will give that a shot and post my final code here. When would I call that script? onReportInitialize()? onQueryExecuted()?
|
||||
|
Depends if you want to tie the action to the query screen or the report.
If query screen, then onQueryExecuted(), if report, onFormOpen(), since onReportInitialize() also fires when the form is refreshed, and you only need to adjust the recordset once. Peter Tyrrell, MLIS Senior Consultant Andornot Consulting Inc. http://www.andornot.com/about/developerblog |
||||
|
Ok, so I am almost there...here's my script so far...it's on a query screen now...
function onQueryExecuted() { var crs; var isOmit = false; crs = Application.activeTextbase.currentRecordset; if (crs && crs.RecordCount > 0) { crs.MoveFirst(); while (crs.EOF == false) { isOmit = false; var projcode = crs.Fields.Item("Project Code").Value; var aCodes = projcode.split("."); var number = aCodes[1]; if (number == "00") { crs.OmitCurrentRecord(); } else crs.MoveNext(); } } } The only problem now is that while it shows the correct number of records, the first 00 code appears at the top of the list (the report is sorted by project code, and project code is a CODE field.) Only when I hit F9 to refresh the screen do the right records show...they show up correctly on the print preview...any ideas? |
||||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

