Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Grid button

52 views
Skip to first unread message

Marc

unread,
Dec 15, 2009, 12:24:59 AM12/15/09
to
I'm calling a form by using a
button which is in a grid column.
Grid's RecordSource is "Alias1"

In the loading form Init event there is a SELECT command to select Alias2
SELECT (Alias2)
But after executing that SELECT command
still the selected alias is "Alias1"(Grid RecordSource)

What is the reason for this?
How to avoid this?
Pls help.

Stefan Wuebbe

unread,
Dec 15, 2009, 2:02:28 AM12/15/09
to

That's how the Grid class behaves - it's notoriously trying
to keep its RecordSource alias being the currently selected
work-area.

> How to avoid this?

You can probably either use a private datasession for the
second form.
Or move the "focus" elsewhere, e.g. in first form do a
"Thisform.dummy.SetFocus()".

In addition, in many scenarios the effect may not matter
much, since custom code works better if it does not rely
on the current work-area being a certain alias anyway.
IOW, better do not omit the IN clauses, alias parameters,
that many Vfp commands and functions have.


hth
-Stefan

Marc

unread,
Dec 15, 2009, 3:46:45 AM12/15/09
to
Thanks Stefan,

Yes I can use Alias name in some functions
But how to give the alias name for following commands?
lcRelation = SET("Relation")
SET RELATION TO


"Stefan Wuebbe" <stefan...@gmx.de> wrote in message
news:uSlqQSVf...@TK2MSFTNGP06.phx.gbl...

Jürgen Wondzinski

unread,
Dec 15, 2009, 5:25:10 AM12/15/09
to
Hi Marc,

Since you can have multiple Relations going into different child tables, the
use of SET("RELATION") is not the correct way to retrieve your existing
relations. That SET() could only return one of that settings. That's why
"RELATION" is also not listed in the Intellisense Dropdown list for possible
SET() parameters.

You can get a correct answer using the RELATION() function, which is also
equiped with an ALIAS parameter. That function, btw is also listed as SEE
ALSO in the SET RELATION command help.


A little more complicated is the second command. The correct command here
would be SET RELATION OFF, but that one somehow didn't got the "IN cAlias"
extension.
The other SET RELATION TO would have the IN clause, but the correct syntax
is a little bit tricky:

SET RELATION TO IN cMasterAlias
will get you an error. But this one works:
SET RELATION IN cMasteralias TO

But again: The better way would be to use a Private Datasession in your
childform. You would need to transfer the current recordnumber as parameter
to that form, so that it knows which record you're sitting on in the master
form.


--

wOOdy
Visual FoxPro Evangelist
Microsoft "Most Valuable Professional" 1996 to 2009

"*��)
�.���.�*��) �.�*�)
(�.��. (�.�` *
..�`.Visual FoxPro: It's magic !
(�.�``��*

Marc

unread,
Dec 17, 2009, 12:16:33 AM12/17/09
to
Thanks J�rgen Wondzinski

"J�rgen Wondzinski" <jue...@wondzinski.de> wrote in message
news:%23yJVlDX...@TK2MSFTNGP06.phx.gbl...

> "*��)
> �.���.�*��) �.�*�)
> (�.��. (�.�` *
> ..�`.Visual FoxPro: It's magic !
> (�.�``��*
>

0 new messages