I have made a form that I wish to use to alter tables in an existing database.
All is working OK except for 1 bit.
I used the example in faq184-4104
The only changes being that I used variables for the table name and field names.
The function:
failed with the variable lcFname. The function is looking for
the correct syntax
here is the entire code:
Any help would be appreciated
All is working OK except for 1 bit.
I used the example in faq184-4104
The only changes being that I used variables for the table name and field names.
The function:
Code:
ALTER TABLE (lcTable) ADD COLUMN (lcFname)
failed with the variable lcFname. The function is looking for
the correct syntax
here is the entire code:
Code:
LOCAL lcFname,lcTable,lcTYpe,lcname
lcTable=thisform.text1.Value
lcname=thisform.text2.Value
lcTYpe=thisform.text3.Value
lcTable=ALLTRIM(lcTable)
lcname=ALLTRIM(lcname)
lcTYpe=ALLTRIM(lcTYpe)
lcFname=lcname + " " + lcTYpe
SELECT 0
USE (lcTable)
AFIELDS(laFields)
IF ASCAN(laFields,lcname) > 0
* the field already exists
* close the table, and go on our merry way
USE
ELSE
* reopen it - this time exclusively so we can modify the structure
USE (lcTable) EXCL
* The USE command closes the table (if necessary) and then tries to reopen it.
* Therefore, the table will not be open if the Exclusive-Use failed, even if
* it were open prior to it.
IF USED(lcTable)
* opened exclusively okay
ALTER TABLE (lcTable) ADD COLUMN (lcFname)
* now close it
USE
MESSAGEBOX("Update Successful! - The new CalcMethod field has been " +;
"added...","MyClientName")
ELSE
* Houston, we have a problem.
MESSAGEBOX("Update Failed! - Unable to add the new CalcMethod field " +;
"because the joblist table cannot be opened exclusively at this time. "+;
"Have everyone exit the System and try it again.","MyClientName")
RETURN
ENDIF
ENDIF