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

Senior moment - use a dbf 1

Status
Not open for further replies.

coldan

Programmer
Oct 19, 2008
98
AU
Set Default To (mydatapath) < defined variable

If File("TL-All.dbf")

myfile = "TL-All"

If !Used(myfile)
Use (myfile) In 0
Endif

Select (myfile)

Endif

alias() (TL-All) does not show in debugger so I tried another table and different command style.

If !Used("tl-web")
Use tl-web In 0
Endif

Select tl-web < form will not compile this line


Can anyone help me with this?

Thanks

Coldan
 
Coldan,

1. Are you sure TL-All.DBF exists in Mydatapath?

2. In the SELECT, is there are a space between the word "select" and the open paranthesis? This is important because SELECT can either be a command or a function.

3. When you say "Select tl-web" does not compile, what exactly is happening? Do you see an error message?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks Mike,

1 Yes, and it opens from a X2 click with VFP

2 Yes, there is a space - Select sp (myfile)

3 This code is on a button in a form - it tries to close but the error says 'Command is missing required clause'

when I try Select 'tl-web' - the form closes without error

I commented out all code on this button but for the line

Select tl-web

I get the same error message.

I'm puzzled.

Coldan
 
Coldan,
It is simple in fact. VFP uses letters, digits and uinderscore in alias names and nothing else. It would make the alias name of such a table name "tl_all".

Code:
if File("TL-All.dbf")
    myfile = "TL-All"
    myalias = chrtran(m.myfile,'-',_')

    If !Used(m.myAlias)
        Use (m.myfile) In 0
    Endif

    Select (m.myAlias)
Endif

If !Used("tl_web")
    Use tl-web In 0
Endif

Select tl_web

Of course you can explicitly set another alias:

Code:
Use ('tl_all') In 0 alias tlAll


Cetin Basoz
MS Foxpro MVP, MCP
 
PS: - wouldn't work in an alias name because it is an overloaded string operator in VFP. ie:

Code:
FirstName = "Coldan      "
LastName = "Smith"

fullName = m.FirstName-m.LastName
? m.fullName+'/' && ColdanSmith and then trailing spaces


Cetin Basoz
MS Foxpro MVP, MCP
 
Thanks Cetin and Mike,

I had my suspicions about the - in the filename. However, the third party app that I write add-ons to accepted my new table without a murmur so I didn't click and didn't know how to get around it.

So thanks once again - you both have been very helpful to me.

Coldan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top