I have identified a problem with SETFILTER because of a suspect data field. The following line of code is not working… table1.SETFILTER(table1.Reference,table2.Reference); …because there is a leading blank in the text field table2.Reference e.g. ’ ABCD’. A matching record is not being found on table1, which also has a leading blank in the reference field. If I remove the blank manually in both tables the filter works as expected. Has anyone experienced this before and come up with a way of getting this to work? (aside from removing all blanks when the text field is populated), Thank you in advance
Can you not just use Table1.SETRANGE(Reference,Table2.Reference); Have you tested what happens with SETRANGE?
Try table1.SETFILTER(table1.Reference,’%1’,table2.Reference); I had already tried this, but it made no difference >> Table1.SETRANGE(Reference,Table2.Reference); I had not previously tested this but have now, and again it made no difference.
…because there is a leading blank in the text field table2.Reference e.g. ’ ABCD’.
Originally posted by peatc - 2005 Apr 22 : 15:17:23
Are you sure it is a leading ‘blank’? Not an other character the client shows as a blank. Because if it IS a ‘blank’ the setfilter with ‘%1’ must work. Maybe a client problem. Which client version are you using (please check the properties of the fin.exe as well).
Yes I am sure it is a leading blank. I know this is the case because to reproduce this error in our test environment I’ve had to manually change some data. The file version I am using is 3.60.00.12822
Hi Peter, is the field you are filtering a Text or a Code field? br Josef Metz
The reference fields in both tables are text fields, length 30.
You can try this method to remove blanks table1.SETFILTER(table1.Reference,DELCHR(table2.Reference,’<>’,’ ‘); DELCHR(table2.Reference,’<>’,’ ‘) - removes spaces My Sample code works perfectly text1 := ’ Hello World’; message(text1); text2 := DELCHR(text1,’<>’,’ '); message(text2); The output of text2 is - ‘Hello World’ Hope this will help you
Peter, I tested my suggestion at 3.60 build 15069 in the native database and was able to get it to work. Are you using SQL?
Removing the blank from table2.reference does not help in this case. This is because I am filtering a recordset to check if a record already exists, and in this case it does. i.e table1.reference = ’ ABCD’. However, I have retried Nelson’s suggestion and used SETRANGE, and this now appears to be working as I would expect. I hadn’t reloaded my test unit properly so didn’t pick up this change when I was testing it earlier. Many thanks to you all for your help.
I also ought to point out the Zarryn’s suggestion of using … table1.SETFILTER(table1.Reference,’%1’,table2.Reference); …also seems to work now. Again, for some reason, I was not picking up this change when I was testing this the other day. Thank you all again.
Great, nice to hear that. The problem was getting stranger with every post! [:D]