04.08.2013 Views

Printing - FoxTalk - dFPUG-Portal

Printing - FoxTalk - dFPUG-Portal

Printing - FoxTalk - dFPUG-Portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

a record in the .SCX. Two fields in the .SCX that are of interest here are the Class and Classloc<br />

fields. By default, all forms created are based on Visual FoxPro's base class definition.<br />

Therefore, the default values of Class and Classloc are Form and an empty string, respectively.<br />

Assume that your class definition, called 'MyForm', is contained in 'MYLIB.VCX'. Further<br />

assume that MYLIB.VCX is contained in the same directory as your .SCX. It's merely a task of<br />

changing the values of Class and Classloc to 'MyForm' and 'MYLIB.VCX', respectively. When<br />

changing the Classloc value, make sure to enter the relative path if the class library isn't in the<br />

current directory. Finally, close the .SCX and open the form. Your form should now be<br />

inheriting from your MyForm class.<br />

For those of you who have the Professional Edition (and therefore the Class Browser), the<br />

procedure is a bit simpler. First, open the Class Browser and instead of opening a class library,<br />

open your form. Next, with the form reference highlighted in the outline control of the browser,<br />

press the Redefine button. You'll now be presented with a dialog box to enter a class definition<br />

and the visual class library in which the definition resides. In this example, it will be Redefine<br />

As 'MyForm' Of 'MYLIB.VCX'. Finally, press the Redefine button to save your<br />

changes. The form will now inherit from the 'MyForm' class.<br />

In both cases, I encourage you to make a backup of your form so that you can recover from any<br />

mistakes.<br />

I have a form that uses a series of tables and views. All of the cursor objects in the Data<br />

Environment are set to optimistic table buffering. Additionally, all of the views have the<br />

Send SQL Updates check box checked. Whenever I make changes to a view and issue a<br />

TABLEUPDATE() and subsequently close the form, I get an uncommitted change error<br />

referencing the table that is associated with a view even though a TABLEUPDATE() was<br />

issued. What could possibly be the problem?<br />

The behavior you're encountering actually makes sense when you break the steps down. Views<br />

will respect the buffers of the tables upon which they are based. Since the tables that your view<br />

is based on are already open and are in optimistic buffer mode, when you update a view it<br />

updates the underlying table's buffer, not the disk. Therefore, you must make a final pass through<br />

your tables to commit any changes that have been made. Code similar to the following will do<br />

the trick: (Assume the name of the view is called 'myview' and the table upon which it is based is<br />

called 'mytable'):<br />

BEGIN TRANSACTION<br />

IF tableupdate(.t.,.t.,'myview') AND ;<br />

tableupdate(.t.,.t.,'mytable')<br />

END TRANSACTION<br />

ELSE<br />

** tell the user there is a problem<br />

ROLLBACK<br />

ENDIF

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!