NetTalk Central

Author Topic: Form with 2nd File  (Read 4095 times)

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Form with 2nd File
« on: November 21, 2012, 05:39:03 AM »
Hi,

I thought I figured this out, but I'm hitting a snag:-

I have a simple Form that updates the Quotes file.
On this Form I populate the Client File as well.

Now, once I press on Save, I want to access:client.insert(), which works fine (in the Validate Insert embed point) and now I have my Client No, but then I want to say q:clientno = cli:clientno, or p_web.ssv('q:clientno',cli:clientno).

For the life of me I tried everything, I can't find the place to put that code so that it work.  I simply end up with no Client No in the Quotes file.

Please help.

Thanks
Charl

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Form with 2nd File
« Reply #1 on: November 22, 2012, 04:52:39 AM »
I'm sorry Charl, I don't understand the question.

Maybe you could set up a small example to shoe what you're trying to do, and post that here?

cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Form with 2nd File
« Reply #2 on: November 22, 2012, 05:45:48 AM »
Hi Bruce,

OK, I am now so useless I cannot even get the example to work properly, but maybe that is because my TPS is kind of non-existent these days.

But I am sure from the example you will be able to see what I am trying to do.

Note, there is an extra file,Client, and it is on the Mailboxes Form as new Tab.

Thanks
Charl

I have been fighting with this since last week Friday, when I actually watched my 1st Webinar 'live' ever, from beginning to end...

Clarion8, NT 6.51

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Form with 2nd File
« Reply #3 on: November 23, 2012, 02:37:23 AM »
Hi Charl,

a couple of pointers;

a) after opening a file you need to do a .UseFile before using it. Especially if you are then gonna use File driver functions like GET.

b) you may want to add p_web._trace statements so that you can inspect what is happening where. For example you do a p_web.SessionQueuetoFile(client) and then use cli:clientno. Are you sure cli:clientno is set correctly there?

c) this bit of code seems unnecessary;
    access:client.open()
    p_web.SessionQueuetoFile(client)
    access:client.insert()
    access:client.Close()


because then all you're doing is

MAI:ClientNo = Cli:clientno
 which could be replaced with

MAI:ClientNo = p_web.GSV('Cli:clientno ')

c) You do a get(client,Cli:KeyClientNo) with no error checking - did the GET succeed?

work with that - and if you need more clues post the updated example again.

cheers
Bruce

charl99

  • Full Member
  • ***
  • Posts: 185
    • View Profile
    • Email
Re: Form with 2nd File
« Reply #4 on: November 23, 2012, 06:59:20 AM »
Hi Bruce,

Thanks for your pointers, yes, I forgot about that UseFile thing, I allways switch that Defer file opening to OFF in Global Properties.  If you have time, maybe you can tell me WHY that thing default to ON and what is actually the reason for that thing?  To me it feels like you just have to write another line of unnecessary code.

Anyway, I finally figured my problem out, most of the time I use Memory Forms, and then I use do openfiles and do closefiles to get the relevant information.  That appears to be a bad idea when you use a Table Form, so by simply putting access:client.open() as opposed to do openfiles, the problem disappeared.

Everyday I learn something.  Thanks.

Cheers
Charl

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Form with 2nd File
« Reply #5 on: November 23, 2012, 08:35:49 AM »
>>  If you have time, maybe you can tell me WHY that thing default to ON and what is actually the reason for that thing?  To me it feels like you just have to write another line of unnecessary code.

When you edit a table, you potentially need to alter data in all the related tables as well. Specifically if you change the primary key value, then the cascading change will affect lots of tables. So when you "open" a table, using the Relate: method it opens the file, and puts all the "related" tables in a sort of "ready, but not open" state. this is lazy opening.

Remember actually opening tables is very expensive, so you don't want to do that more than you have to. By turning off lazy opening you are dramatically slowing down the speed with which your browse opens.

If you use the relate: form of the open, then that's the same as Access.Open, and Access.Usefile _for that primary table_. But you used the Access.Open form, so you need the Access.Usefile call as well.

IMO the speed gain from lazy opening _far_ exceeds the effort of adding an extra line of code - and if you use the Relate.Open instead of Access.Open, you don't even need that.

cheers
Bruce