I started out with a regular database called labels.dbf. I open a form and on
that form there is a grid showing the contents of the labels.dbf.

I decided to use a cursor instead. I create the cursor in the load of the
form. When the form opens it says it can't instaniate the labels.dbf cursor.

How do you tell a grid to wait till the dbf is available? DO I have to
create the grid after I create the cursor? Sounds like alot of work.

Is there a way to have the grid on the form and then tell it what cursor to
use after during the init or load?

Re: I am having a problem tying a grid to a cursor. by Stefan

Stefan
Wed Nov 01 10:28:28 CST 2006


"Phrank" <Phrank@discussions.microsoft.com> schrieb im Newsbeitrag
news:B7AC195B-0C15-4046-A0F0-CD04C613C0D5@microsoft.com...
>I started out with a regular database called labels.dbf. I open a form and on
> that form there is a grid showing the contents of the labels.dbf.
>
> I decided to use a cursor instead. I create the cursor in the load of the
> form. When the form opens it says it can't instaniate the labels.dbf cursor.
>
> How do you tell a grid to wait till the dbf is available? DO I have to
> create the grid after I create the cursor? Sounds like alot of work.
>
> Is there a way to have the grid on the form and then tell it what cursor to
> use after during the init or load?

You can use a (parameterized) view instead. Or prevent "grid reconstruction"
by setting the grid.RecordSource=Space(0) right before requerying the
temp cursor. See also http://groups.google.com/advanced_group_search



hth
-Stefan



--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------


Re: I am having a problem tying a grid to a cursor. by Josh

Josh
Wed Nov 01 10:43:27 CST 2006

assign the record source after you create the cursor

On Wed, 1 Nov 2006 08:13:02 -0800, Phrank <Phrank@discussions.microsoft.com>
wrote:

>I started out with a regular database called labels.dbf. I open a form and on
>that form there is a grid showing the contents of the labels.dbf.
>
>I decided to use a cursor instead. I create the cursor in the load of the
>form. When the form opens it says it can't instaniate the labels.dbf cursor.
>
>How do you tell a grid to wait till the dbf is available? DO I have to
>create the grid after I create the cursor? Sounds like alot of work.
>
>Is there a way to have the grid on the form and then tell it what cursor to
>use after during the init or load?


--- AntiSpam/harvest ---
Remove X's to send email to me.

Re: I am having a problem tying a grid to a cursor. by Jack

Jack
Wed Nov 01 11:38:38 CST 2006

On Wed, 1 Nov 2006 08:13:02 -0800, Phrank
<Phrank@discussions.microsoft.com> wrote:

>I started out with a regular database called labels.dbf. I open a form and on
>that form there is a grid showing the contents of the labels.dbf.
>
>I decided to use a cursor instead. I create the cursor in the load of the
>form. When the form opens it says it can't instaniate the labels.dbf cursor.

The grid's RecordSource property tells it what cursor to use. If you
create that cursor in the form's Load event, then everything should be
fine, since Load runs before the grid is created.

I'm a little confused when you talk about the "labels.dbf cursor". The
.dbf extension implies a database, not a cursor.

>How do you tell a grid to wait till the dbf is available? DO I have to
>create the grid after I create the cursor? Sounds like alot of work.

What dbf? You said you are now using a cursor instead of the dbf.

>Is there a way to have the grid on the form and then tell it what cursor to
>use after during the init or load?

Set its RecordSource property when the cursor is available. However,
when the grid instantiates, if its RecordSource property is empty, it
will use the current work area, if any.

Re: I am having a problem tying a grid to a cursor. by Jeff

Jeff
Wed Nov 01 14:40:47 CST 2006

Basically what everyone else said is what I do. To be a little more
specific, sometimes I have a method which I add to the form called
SetupGrid. This method updates the grid when the data in the cursor needs to
change. It usually looks something like:

thisform.grid1.recordsource = ""
SELECT * FROM names INTO CURSOR shownames WHERE <whatever parameters you
choose>
thisform.grid1.recordsource = "shownames"
thisform.refresh

You can call this method during your init method if there are some initial
records you want to display in the grid. You can also call it whenever
something on your form changes and you need to display different information
in the grid. The key is to set the recordsource property of the grid to ""
before you query and then to set it to your cursor after you query.

If you are building your cursor by hand you would simply substitue your code
for building the cursor instead of the SELECT.

Jeff

"Phrank" <Phrank@discussions.microsoft.com> wrote in message
news:B7AC195B-0C15-4046-A0F0-CD04C613C0D5@microsoft.com...
>I started out with a regular database called labels.dbf. I open a form and
>on
> that form there is a grid showing the contents of the labels.dbf.
>
> I decided to use a cursor instead. I create the cursor in the load of the
> form. When the form opens it says it can't instaniate the labels.dbf
> cursor.
>
> How do you tell a grid to wait till the dbf is available? DO I have to
> create the grid after I create the cursor? Sounds like alot of work.
>
> Is there a way to have the grid on the form and then tell it what cursor
> to
> use after during the init or load?



Re: I am having a problem tying a grid to a cursor. by Man-wai

Man-wai
Thu Nov 02 02:26:06 CST 2006

On VFP 9, there is a form.bindcontrols property to delay data binding.

--
iTech Consulting Co., Ltd.
Website: http://www.itech.com.hk (IE only)
Tel: (852) 2325 3883 Fax: (852)2325 8288