Multiple Browses on one Window, same file, same update form


#1

Hi Folks,

It’s been eight or so years since working in desktop clarion (nettalk junkie), so am a little rusty.

Have got a window with X browses on it, all using the same file (an alias), and all calling the same update form (using that file alias too) on the update buttons template.

The problem is, without any embed code or me “fixing” things, the update form only works on the last browse loaded. Opening the form on any other browse doesn’t open that record but the [edit] selected record on the last browse loaded.

What’s the story here? Do I need to get tricky, or can I just tell clarion to do what it should and open the form I want for the browse I want?

Cheers!


#2

Stu,
The update form is fixed to the table so it isn’t going to update the alias directly.
In the Ask method on the browse for the alias, you need to save the main file info and then fetch the correct row in the main file that the alias browse is on. I would then restore the main file when you return so the browse on the file itself doesn’t reposition to the edited record.
You can use Access:MyFile.SaveFile/RestoreFile to save and restore the main file.


#3

Hey Rick,

Thanks for the reply!

Actually, the update form is set to use the alias as well. Should have made that clearer.

The problem is that it doesn’t open the records on any of the browses EXCEPT the last browse loaded (when there are multiple browses on the one window all for the same alias using the same update form).


#4

Hi Stu,

I don’t recommend using the same table or alias in multiple browses on the same window.

You’ll always be struggling with refresh and position issues.

Create an alias for each of the browses.

Then use the concept I posted in the .Ask methods for each of the browses that use an alias other than the one for the update form.

You could hack the update form and pass in the table/relation manager to use. You’d need to make the USE variables on the form references or ANY variables and then assign the correct fields from the right alias when the procedure starts. It would be a pain, but probably doable. I think the idea of making sure the correct row is in the alias used by the form will be easier.


#5

Right on! Thanks Rick, wonderful stuff. Understand now.

Different alias file for each browse, and at each “open form” point make sure the file record that the form is going to use is retrieved.


#6

The “browse update template” is linked to a browse, so it should be getting the record for whichever browse it is linked to.

The big question is, how will your procedure know which browse it is you want to call the update procedure for?

Once you can figure that out, it is fairly trivial to Access:Filename.Fetch(PrimaryKey) the correct record and call the update procedure, which will then update that record. Have a search in your source code for where the update procedure is called. There is an embed just before that where you can call this sort of code.

I always prefer to update the original file, rather than the alias - might not make much difference?

After returning from the update procedure you can also call whatever code is necessary to update the display of the appropriate browse.


#7

Thanks!

Rick’s process above seems to be working pretty well at the moment :slight_smile:

The big question is, how will your procedure know which browse it is you want to call the update procedure for?

In my initial working the browses were all using the same file, so I would have thought/hoped Clarion would sort out “which browse is calling this” itself, automagically.