Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set console off not working 1

Status
Not open for further replies.

ulises48

Technical User
Feb 3, 2012
17
MX
Hello all: I have:
SET CONSOLE OFF
SET TALK OFF
SET ECHO OFF
And still, when opening some control boxes based on a SQL statement, I get the browse window. What am I missing?

Thank you in advance
 
Queries need to go INTO CURSOR, including queries in comboboxes with a rowsourcetype query, otherwise you get a browse window with the sql result.

Bye, Olaf.
 
SET CONSOLE ON/OFF has nothing to do with browse window popping up, colleague Ulises: it has effect only on the main VFP window.

Besides, I've never seen Browse window popping up when expanding the List part of Combo Box control.
Could you, please, post a screen capture of this "phenomenon" ( :) ), and the code behind it (or settings in the Properties/Data tab, if it's done on design time)? In particular: RowSourceType and RowSource settings.

Regards,

Ilya
 
... but based on what you said about combo boxes and SELECTs, then Olaf has given you the answer. You need to add INTO CURSOR, followed by a cursor name, to any SELECT statement that populates a combo box.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
In addition to the replies of Olav and Mike be sure you use an unique name for each cursor.
-Bart
 
combo boxes based on a SQL statement

You are better off creating a 'static' cursor (or temp table) based on the SQL statement having executed in the Form's LOAD method and create some Index on it which can then be used to control the 'visible' records in that cursor (and its associated ComboBox) as needs dictate.

Good Luck,
JRB-Bldr
 
You are better off

Not necessarily.

There is nothing inherently wrong with a combobox with a query as its source. It is fully self-contained (encapsulated), functional, and portable without dependence on outside factors.
 
There is nothing inherently wrong with a combobox with a query as its source. It is fully self-contained (encapsulated), functional, and portable without dependence on outside factors.

But my preference is to put the query in a combobox method rather than making it the RowSource. I like to have a custom GetItems method called from Init and Requery. The query can go GetItems, along with any other code needed to set the thing up.

Tamar
 
I appreciate all the input. I guess I'm showing off my newbiness :p
@Tamar Could you be more explicit about how to put a query in a method? Please be as specific as possible. I am no expert as you may already know.
 
The way I like to do this is as follows:

1) Subclass the base combobox class to create a generic combobox class to be used throughout the application.

2) Add a custom GetItems method to this class by choosing Class > New Method from the menu and specifying GetItems for the name.

3) In the Init method, put a call to GetItems, like this:

This.GetItems()

4) In the Requery method, do the same thing.

5) Save the class.

Now, when dropping combos on forms, use this new class instead of the VFP combobox class. (There are a number of ways you can do that. I like to use the Toolbox, but you can also do this from the Form Controls toolbar, the Project Manager or the Class Browser.)

Once the combo is on the form, double-click on it to open a code window and switch to the GetItems method. Put the code for your query and anything else you need to set up the combo there. You'll want to set RowSourceType and RowSource. (I actually do this a little differently, but I'm simplifying.) That's all it takes.

When I have a combo that I need on multiple forms (for example, to choose a customer), what I actually do is subclass the class I created above and set the new subclass up exactly as I want it for that particular situation, and then use that class every time I need that particular kind of combo.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top