Set range on insert trigger

This is what I have done: Setrange(var1,var1); Setrange(var2,var2); if find (’+’) then Line no. := Line no. + 10; This works great, but it leaves the setrange on the form. I am looking for suggstion of the best way to clear the filters after the line number has been incremented. I have tried resetting by: Setrange(var1,’’); Setrange(var2,’’); but I get the error Var 1 does not exist, which is pretty obvious, but I cannot see for looking at what I am missing Any Suggestions ?

Hi Use Record.RESET to clear all filters. But probably you may not required to use this function because of the following reason. if we use a setrange again with new values on the same column the previous filter will be cleared and set to new range. Regards Joseph Mathew Edited by - joseph_mathew on 2001 May 30 15:31:21

Do not set range on the database you are trying to insert line into. Instead create another instance of the record → in globals then set range and find the last record and insert the line: here is example: in globals customer1 rec customer in code: customer1.setrange(var1,var1); customer1.setrange(var2,var2); if customer1.find (’+’) then Line no. := customer1.Line no. + 10; then insert your record. the original datatable will not have any filters.

quote:


Originally posted by Dean Axon: This is what I have done: Setrange(var1,var1); Setrange(var2,var2); if find (’+’) then Line no. := Line no. + 10; This works great, but it leaves the setrange on the form. I am looking for suggstion of the best way to clear the filters after the line number has been incremented. I have tried resetting by: Setrange(var1,’’); Setrange(var2,’’); but I get the error Var 1 does not exist, which is pretty obvious, but I cannot see for looking at what I am missing Any Suggestions ?


Many Thanks !! Rec.reset worked fine, but I would like to extend the conversation on the customer1.line no. just so that i am understanding correctley Stupid question, but you assign that to temp ??

be carefull with RESET it changes current key too. To remove filters from field use: Setrange(var1); Setrange(var2); instead of Setrange(var1,’’) - it sets fillter ‘’ (all empty fields).

Believe there’s some confusion. Setrange needs to have the field specified, so actually your code will look like tablename.SETRANGE(Fieldname,Var1,Var2), whereby Var1 is the minimum and Var2 the maximum value. Applying a filter on the table before you retrieve the latest linenumber needs some precaution to avoid running into creating duplicates. Doing your retrieval with a separate variable of type (temp) record is a good way of keeping control over what’s happening. Clearing a range or filter on a field, while other filter are untouched is done best by tablename.SETRANGE(Fieldname,’’) Note: Be aware of the subtle, yet important difference between SETRANGE(field,’’) and SETFILTER(field,’’). The first one actually clears the filtering and returns all records, whereas Setfilter only returns the records without a value in the field! John

If you need to insert line in “customer table” then you need to find “Line No.” for the last record so that you can increment “line no” and insert new record. Declare new variable under globals. This variable should be a type “record” of the same table you are trying to insert line in. Once you have that variable let say “Customer1” then find your last line and 10 and insert record in the original table. Side note: if you are looking for the last record do not set any filters.

quote:


Originally posted by Dean Axon: Many Thanks !! Rec.reset worked fine, but I would like to extend the conversation on the customer1.line no. just so that i am understanding correctley Stupid question, but you assign that to temp ??