Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Table for controlsource not found
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00057660
Message ID:
00058009
Views:
36
>>>I have a form with a big grid whose .RecordSource is the one table in the DE. If I set grid.ColumnCount = -1, the form works fine, with the grid showing me all fields in MyTable. If I make a column and set the .controlsource = MyTable.Myfield, it gives me Error Loading File - controlsource - record number 4 - Alias 'Mytable' is not found. My controlsource was selected using the little combo in that field in the properties form, so I didn't have the opportunity to mis-type the controlsource. What's going on?
>>
>>Bret, check in your DataEnvironment to see if AutoOpen is .T. Next try to re-create the grid using the standard VFP builder.
>>
>>HTH
>>Barbara
>
>My DE.AutoOpenTables = .F. because I have a class to change the .Database path to the current folder. I instantiate the database path-changing class in the .Load of the form class. It always worked until now. Setting my DE.AutoOpenTables to .T. makes the form work, and effectively hard codes the path to the table, which is unacceptable. Here is my path-changing code:
>
>In the form class .Load:
>
>SET TALK OFF
>oChangeDataPath = CREATEOBJECT('datafolder')
>oForm = THISFORM
>oChangeDataPath.curfolder(oForm)
>RELEASE oChangeDataPath
>RELEASE oForm
>
>
>My "datafolder" class has a method called .curfolder which looks like this:
>
>
>PARA oFormcalled
>* This class resets the paths of tables in the data environment
>* to CURDIR()
>IF PARAMETERS() = 0
> RETURN
>ENDIF
>IF TYPE("oFormcalled.DataEnvironment") = "O"
> oEnviron = oFormcalled.DataEnvironment
>ELSE
> RETURN
>ENDIF
>IF TYPE("oEnviron") = "O"
> nTotMem = AMEMBERS(aMems,oEnviron,2)
> WITH oEnviron
> IF .AutoOpenTables = .F.
> * Check for cursors
> FOR i = 1 TO m.nTotMem
> IF UPPER(EVAL("."+aMems[m.i]+".BaseClass")) = "CURSOR"
> WITH EVAL("."+aMems[m.i])
> STORE .Database TO cDB
> cDB = SUBSTR(cDB,RAT('\',cDB)+1)
> .Database = SUBSTR(FULLPATH(cDB),1,RAT('\',FULLPATH(cDB)))+cDB
> ENDWITH
> ENDIF
> ENDFOR
> .OpenTables()
> ENDIF
> ENDWITH
>ENDIF
>RELEASE oEnviron
>
>
>I tried a WAIT WINDOW in the .Load just before the code that instantiates the class, but the error occurs before it hits the .Load code.

Here's an update. My form is based on a browse form class (which is based on a base form) which has the above .Init code, a grid with .ColumnCount = -1 and no RecordSource. When I use this form class, I put a table in the DE, set .AutoOpenTables to .F. (so the code in my datafolder class above will work), and set the grid.Recordsource = mytable. This works, until I set .ColumCount > 0 and make some columns with .ControlSource = mytable.myfield. Then it says "alias 'mytable' not found" before it can execute any of the Form.Load code. Moving the Form.Load code from the class to the form itself made no difference.

I had an idea. I just made a similar form, but this time I used my base form and put a grid on it, rather than using a form class with a grid already in it. Everything else is the same. Now it works. So I basically had to get the grid out of my browse form class, and put a unique grid in each instance. That's fine, but why did this happen?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform