Simplicty and flexibility!


GoTo Last Record in Sub-Form


Started by Jeyarajah Arulrajah
Search
You will need to Sign In to be able to add or comment on the forum!

GoTo Last Record in Sub-Form

I have a main-form and sub-form.

Would like to create a button on the main-form.

When I click on that button, I would like the cursor to go into the last record of the sub-form and show that on the screen.

Is this something possible?


Written by Jeyarajah Arulrajah 30/11/18 at 02:28:14 Dataease [{8}]FIVE

Re:GoTo Last Record in Sub-Form

Sorry Arul but you aren't very clear.

Do you want to scroll to the last record in Subform and give it focus or do you want the last record in subform to be opened in its "main form" i.e. open related?


Written by DataEase 30/11/18 at 12:20:41 Dataease [{8}]FIVE

Re:Re:GoTo Last Record in Sub-Form

I know latter is easy to do.

I want the scrolling option ?


Written by Jeyarajah Arulrajah 02/12/18 at 02:34:40 Dataease [{8}]FIVE

Re:Re:Re:GoTo Last Record in Sub-Form

Should have guessed ;-)

What is the use case i.e. how is the functionality of the form and in what cases do you want to go to the last record.

Given a specific task and target I'm sure we would be able to fix it but there isn't any defined function for this. 


Written by DataEase 02/12/18 at 12:42:31 Dataease [{8}]FIVE

Re:Re:Re:Re:GoTo Last Record in Sub-Form

Think of it expenses form for each year.

On the main-form, you will have tax year, and other details.

In the sub-form, you will enter all the expenses for that year.

But, each time entering a new expenses needs the new line in the sub-form. That means you have to scroll down all the way to new line to enter new expenses.

I hope this makes sense.


Written by Jeyarajah Arulrajah 02/12/18 at 22:27:13 Dataease [{8}]FIVE

Re:GoTo Last Record in Sub-Form

Download Sample


Hi again Arul.

I remember we worked on things like this in 8.5 but we never really "attacked" the subform.

The main focus in DE9 is not the FRM/GUI format but we have still fixed the Buttons, Styling, TabControl and are currently fixing the MultiBox (Lookupfield) so maybe we should have a go at SubForms too. It would be nice to have better control with them. I will make a note of it.

Anyhow, your task is quite straight forward. We only use SetFocus() and KeyStrokes().

Action on button as follows: 
SetFocus("Name#8")+KeyStrokes("_SHIFT(_pgdn)")

The first column in our subform is Name and as we have 8 rows we set focus on the last row i.e. SetFocus("Name#8").

Then we simply send the command to go to the end of the subform i.e. SHIFT PageDown.

Done deal.


Written by DataEase 03/12/18 at 12:35:00 Dataease [{8}]FIVE

Re:Re:GoTo Last Record in Sub-Form

Problem with this one. When you have 20 records in your sub-form. It does not go to the last new record.


Written by Jeyarajah Arulrajah 03/12/18 at 15:28:42 Dataease [{8}]FIVE

Re:Re:Re:GoTo Last Record in Sub-Form

Arul, of course it does.

This is to show you the general idea, you have to adopt it to your application yourself.

Name#8 means the 8 object (clone) of object Name. So if you want to go to 20 you use to do Name#20

It doesn't matter if the new record is inserted in the last row in the subform if you have less than 20 records already but if you want to make it neat you can simply 

if (count of MyRel>20 , SetFocus(concat("Name#",count of MyRel+1)),SetFocus("Name#20")+Keystrokes("_SHIFT(_pgdn))"))

We don't offer key ready solutions, we put you in the right direction.


Written by DataEase 03/12/18 at 18:13:29 Dataease [{8}]FIVE

Re:Re:Re:Re:GoTo Last Record in Sub-Form

Just downloaded your sample database. It works as I wanted this to work.

But, when I try the same technique on my database it is not working. My form has multiple sub-forms.

With rows going up to 20....

When I click on the button, focus going onto 20th record on the first page of the sub-form then only once page down.

But, in your sample database it is going all the way down to the last record. How is this possible?


Written by Jeyarajah Arulrajah 03/12/18 at 18:39:47 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:GoTo Last Record in Sub-Form

Download: ScrollLast.zip

Here is your sample database edited with more data. Please look at the first record in the main form. Then click on the button to see it does not work. I am using 8.5.


Written by Jeyarajah Arulrajah 03/12/18 at 18:45:58 Dataease [{8}]FIVE

Re:GoTo Last Record in Sub-Form


Arul, I see your problem and it is your problem ;-)

A form is not data led.A subform is a GUI object that you can manipulate. The form itself has nothing to do with the data that will populate it.

When you use SetFocus() you set the focus to the GUI  object (clone) not the row in the data. When you scroll data the data will move from one gui object to the next.

In my sample what I do is to move to the last row in the GUI grid and then I send the keystroke for the GUI object to scroll to the first free row.

You manipulate the functionality not the data. 

So my sample works for any number of rows in the subform as it will simply jump to the last row in the Subform Grid and then scroll down.

Yours won't work because you jump to an Clone that doesn't exist. You have done the opposite of what I said. My fix with count of was intended to make it look nicer when there is less rows in data than in Grid.

I must say that I'm not a big fan of the navigation in SubForms so this little "project" has been a little eye opener.

I thought that Shift-Pagedown brought you to the end but it doesn't. It is just pagedown. Documentation for this being great of course...

After a little play I found that that "magic" is CTRL-END CTRL-END CTRL-END CTRL-HOME 

Yes, it sound crazy but the way it works is as follows:

First CTRL-END will go to the end of the current record i.e. last column.
Second CTRL-END will go to the last column in the last row in the Subform.
THIRD CTRL-END will go to the last column in the last row in the DataSet...
And as the logic is the same in reverse a final
CTRL-HOME will go to the first column in current record.

Brilliant....

I think we need to add some SetCurrent() functions for this.

But this figured out your task get very easy.

You simply only need to enter the first column/field in the first row of the subform and then send the correct keystrokes.

In my case:
SetFocus("Name#1")+Keystrokes("_CTRL(_end) _CTRL(_end) _CTRL(_end) _CTRL(_home)"))


Written by DataEase 03/12/18 at 19:16:58 Dataease [{8}]FIVE

Re:Re:GoTo Last Record in Sub-Form

That worked!
This is a very simple function. When you have sub-form feature in DataEase, we need this function.
It's like Google building a nice email client with conversation view. But, we are not allowed to turn that off for a while. They just made that off button available for smart phones....


Written by Jeyarajah Arulrajah 03/12/18 at 20:28:51 Dataease [{8}]FIVE

Re:GoTo Last Record in Sub-Form


I discovered a flaw.

When the subform is less than full you need one CTRL-End less.

SetFocus("Name#1")+if (GetValue("Name#12")=blank , Keystrokes("_CTRL(_end) _CTRL(_end) _CTRL(_home)"),Keystrokes("_CTRL(_end) _CTRL(_end) _CTRL(_end) _CTRL(_home)"))

I used this but it is not "bullet proof".

In 8.x we have taken functionality completely off the "grid" as intended when DFW was started with Express.

It was supposed to be a simple "Duplo" style tool where you used standardised objects with pre-defined features.

OML help a little but as they never really added interesting event and methods it wasn't magic.

One need to take a look at each object with fresh eyes and define what is to be default functionality and what should be configurable with functions/settings.

We are currently working with Multibox which has been a useless feature both slow, messy and "cryptic".

Now by default it will sort. cache, make a unique list and limit the returns to 100. 

This way the default version will be a sorted list of no more than 100 i.e. a populated choice list in order.

But you can also make it a combobox, you can build it on a dynamic relationship and you can freetext search it.



The way the search works is that you type. Then if you have over a second break in typing it will search in your list.

If you have typed in 3 letters or less it will search from front of choice. If  you have typed 4 or more it will do freetext search in list.

Same with the updated TabControl.



Default now when you insert a TabContol it will start with 3 tabs.

You can change the text on the tab without changing the object name.

There are actions and OML handling on each tab.



You can click on the tab itself and style, change colours etc. No longer do you have to first click on tab and then in tab rectangle to chnage feature.

By default TabControl look modern and "nice". You can set the padding around text and you can also set which of the tabs you want to be default. No longer will it save the last one you worked on as the default one.

Another New feature in DE9 along the same practical line is:

1. When you copy an object with a style, the copied object will retain style.
2. When you select several objects of different class they can all be styled simultaneously if there is a style for that class with a matching name.
3. You can now select multiple object and change color/font/fill etc. directly on all of them without using style.
4. If you change the fill on ex. a button and the border has the same colour as fill it will change border at the same time.

These are just small enhancements to show how we think around the product and ease of use.

We want to make the default as good/useful as possible when at the same time making it easy for you to configure it so you get it exactly as you want.

DE9 will be the version where we take the step away from Windows GUI but at the same time it will be the best WIndows version of DataEase/Best version of DataEase ever.


Written by DataEase 03/12/18 at 20:49:19 Dataease [{8}]FIVE
DG3_ForumList