I have a form with an embedded view, a button and two fields (Check and NumDocsInView) There is also a hidden view called GeneralRecFileCatTotal in the database. The first column in this is sorted and the remainder normal.
The code in my button is as follows.
@SetField(“Check”;“3”);
result := @Elements(@DbLookup(“”:“NoCache”;“”:“”;“GeneralRecFileCatTotal”;TopCompanyName;2));
@SetField(“NumDocsInView”;reult;2)));
@Command([FileSave]);
@Command([Compose];“CheckList”)
This button looks up the hidden view and should count the number of documents in the database that match the key TopCompanyName and return the number. The button also creates a new document that appears in the embedded view and so should also enter the hidden view however this only works when you open the database the first time or else you need to open and close the database to see @Dblookup returning the correct count.
Could you suggest any reasons why it is not returning the correct value from the hidden view.
Hi. I apologise I copied and pasted code there. The code is in fact
@SetField(“Check”;“3”);
result := @Elements(@DbLookup(“”:“”;“”:“”;“GeneralRecFileCatTotal”;TopCompanyName;2));
@Prompt([Ok];“”;@Text(result));
@SetField(“NumDocsInView”;result);
@Command([FileSave]);
@Command([Compose];“CheckList”)
. I think it is something to do with the fact that the Hidden View is not refreshing while the database is open. Yet my embedded view does which is itself a hidden view.
I have done another bit of playing around with code and I think I can say that it is the actual @DbLookup that is not working. I am boogled. So the @DBlookup does not work unless I open up the database fresh each time I use the button.
Is your lookup view categorized? Also, try adding the “NoCache” param to your dblookup. This should cause the view to refresh just prior to the lookup. However, I’m not sure that has anything to do with it cuz if there are any entries in the view at all it should still return a count, even if the count is not accurate.
Hi there, I have tried it both with a the first column categorized and just sorted and neither works. Also it does return a value but it is just not accurate if I create any more entries that enter the hidden view.
E.g. When I open the database first I enter a document (Doc A) and then I go to where my embedded view is. ( I am not using this for the lookup because it has two categorized columns in it and I only need one for the lookup). I press the button above the embedded view. There are 4 documents (Doc B)created with a different form that are shown in the embedded view) So when I press the button I get the count back as 4… All perfect. Now I create another document (Doc B) and there are now 5 docs in the embdeed view but when I press the button it says there are still only 4 documents. If I exit the database and reenter and repeat the process it gives the correct result.