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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with NewObject METHOD

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
Hi,

I'm using a treetable object on my main form, which is linked to a table in which there is a field called DoCmd which I call using Execscript (in VFP7).

The procedure runs a SELECT that works fine. It then tries to run Mainform's NewObject method. This fires (I have a wait window in the method) but the object isn't added.

Here is the code I'm using:-

Code:
WITH Mainform
WAIT WIND TIME 3 "Mainform has " ;
 + ltrim(str(mainform.controlcount)) + " objects"
.Newobject("GrdBankings","_fgrid","febaukbase")
WAIT WIND TIME 3 "Mainform now has " ;
 + ltrim(str(mainform.controlcount)) + " objects"

Both wait windows shown here report 27 controls in Mainform.

Any ideas where I am going wrong?

Thanks,

Stewart
 
Stewart
I can't seem to duplicate the problem. I made a form with one button and in the click I have:
Code:
WAIT WINDOW TRANSFORM(THISFORM.ControlCount) && Here I get 1
WITH thisform
.newobject("command2","commandbutton")
WAIT WINDOW TRANSFORM(THISFORM.ControlCount) && Here I get 2
.COMMAND2.VISIBLE = .T.
ENDWITH
Have you checked the Locals in the debugger if you grid is in fact added to the form?
 
Mike,

Thanks.

Yes, running the code in the table's Action memo field in the development environment works fine, but it doesn't seem to work running in the exe.

In the exe, when I move the code into a menu item it works fine. I must be missing something.

Any further suggestions would be appreciated,

Stewart
 
Further experimenting at the command line reveals that if I pass NewObject a non-existent Class Library name, it doesn't do anything. There is no error - presumably it is designed so that it doesn't do anything if it can't find the library.

However, the class library is definitely included in the project, so I would have thought running the code in the exe would work.

Stewart
 
Stewart,

I always had trouble with NewObject, because like you say it doesn't return an erro if the class is not found.
I wonder if you can switch to addobject:
IF !"myLib" $ SET("CLASSLIB")
SET classlib to mylib.vcx ADDITIVE
ENDIF
And:
WITH THISFORM
.ADDobject("command2","myLib")
ENDWITH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top