TOPIC: Found a bug in 'AccessGoTo' code
#652
Found a bug in 'AccessGoTo' code 3 Years, 6 Months ago
Hi, I have found a bug in the AccessGoTo code. This class (that it's not documented in the User's Manual) is used in KeyListView code to display an Access window when you click on the Access button (inside the window that appears when you click on an IdControl) and to display inside the Access exactly the record you chosed.
The problem is with the newRecord param: when set at true, it should start a new record in the Access window, but actually it doesn't work.

The guilty is the .GetChild() inside the wrapper definition of AccessGoTo class:

Code:


wrapper: Controller
{
New(@args)
{
...
if args.newRecord is true
{
ctrl = .GetChild().GetChild()
if ctrl.Method?('On_New')
ctrl.On_New()
}
}
...
}


I don't know why, but as you can see it is repeated two times. In this way the ctrl variable will not get an AccessControl, but a VertControl. Instead, if you use only one .GetChild() the code will work:

Code:


wrapper: Controller
{
New(@args)
{
...
if args.newRecord is true
{
ctrl = .GetChild() // <-- deleted repetition
if ctrl.Method?('On_New')
ctrl.On_New()
}
}
...
}



You can try on an Access in your lib, doing something like (I have imported the lib 'mylib' of the tutorial in the User's Manual):

AccessGoTo('My_ContactsAccess','','', newRecord: true)

Without the above mod, the newRecord param doesn't do nothing, instead if you delete a .GetChild() repetition, the instruction will work.
 
 
Mauro
 
#654
Re:Found a bug in 'AccessGoTo' code 3 Years, 6 Months ago
Thanks Mauro, I'll add the fix to stdlib.

We do not use this feature in our applications, although someone must have needed it sometime.

Maybe in the past the control layout was different and required two GetChild's.
 
 
andrew
 
#655
Re:Found a bug in 'AccessGoTo' code 3 Years, 6 Months ago
Hmmmm... what if the Access is inside a Controller? That is necessary if you need to handle any messages (e.g. buttons)

Maybe it would be better to use FindControl:

Code:

if false isnt (ctrl = .FindControl('Access')) and
     ctrl.Method?('On_New')
     ctrl.On_New()

 
 
andrew
 
#657
Re:Found a bug in 'AccessGoTo' code 3 Years, 6 Months ago
I don't know why you would pass to AccessGoTo a Controller with an Access inside it if the first param of the CallClass is named 'access' and the name of the class is AccessGoTo... Anyway with your mod it would be considered this case too.
 
 
Mauro
 
#658
Re:Found a bug in 'AccessGoTo' code 3 Years, 6 Months ago
Imagine you modified My_ContactsAccess to be:

Code:

Controller
     {
     Controls: (Access (Form ... (Button Print) ...
     On_Print()
         ...



Almost all our application Access's are wrapped in Controllers. And when we use AccessGoTo we want it to run the Controller, not just the Access (otherwise buttons etc. would not work).
 
 
andrew