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

Problem opening foxpro tables using visual foxpro classes

Status
Not open for further replies.

viking2020

Programmer
Jul 9, 2003
7
US
Hello all
I am new to foxpro. I am a having problem opening databases in visual foxpro.I want class B to open up all my tables(using use command) so that i can use the tables in other classes (by using select command). I see that the tables opened using USE command are restricted to the current class (When i try opening comp table in Class A it gives an error saying alias not found).I would great if someone could tell me how to use the open tables in other classes.


* Example code
* A.prg
DEFINE A as Custom

proc method1()
SET PROCEDURE TO B.prg
DO B
objB = createobject("B")

objB.method2()
select comp && Gives an error saying 'Alias comp not found'

endproc

enddefine



* B.prg
DEFINE B as Custom

proc method2()
USE comp
endproc

enddefine


Thanks
Balaji
 
Build small .prg file as your startup file (main) and open there whatever you need to open, also, put there your PUBLIC variable.
 
oops, send too soon :)


create main.prg something like this:


PUBLIC myVar1, myVar2, myVar3
myVar1='Something'
myVar2=33

OPEN DATABASE myDatabase
USE myTable1 in 1
USE myTable2 in 2
USE myTable3 in 3
USE myTable4 in 4

do yourProgram


After that, in your A.prg you can use SELECT.
 
Thank you very much stoko. Your solution is very simple.

Balaji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top