Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using thisform in ComboBox.RowSource
Message
From
08/11/2013 14:50:12
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
 
 
To
08/11/2013 13:59:49
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP3
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01587572
Message ID:
01587576
Views:
76
>I want to use:
>SELECT * FROM MyTable WHERE MyField = thisform.MyObject.Text
>in ComboBox.RowSource property but I get error message that Thisform can be used only in methods.
>
>How to solve this?

One way is to use a custom form method to create a cursor for the ComboBox, and then set the ComboBox.RowSource:
* ComboBox.Init( )
DODEFAULT( )

ThisForm.ComboBoxRowSourceSet( This, ThisForm.MyObject.Text )

* Form.ComboBoxRowSourceSet
LPARAMETERS loComboBox, lcText

SELECT SomeColumn FROM MyTable WHERE MyField == lcText INTO CURSOR SomeCursor

WITH loComboBox
  .RowSourceType = 2
  .RowSource = "SomeCursor"

  .Value = SomeCursor.SomeColumn
  .Refresh( )
  * ComboBoxes are tricky, you may need to play around with setting various properties
  * to get it initialized the way you want

ENDWITH
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform