Syntax Check - please.

I am sure i already posted this question, but it seems to have disappeared??

Is the syntax of my code snippet below correct, as my app can’t find “AC.db” ?
db.DatabaseFile = GetFolderItem(SpecialFolder.ApplicationData.Child(“Accountancy Suite Data”).Child(“AC.db”))

If the code compiles, then the syntax is correct.

It may not be semantically correct if the “Accounting Suite Data” folder does not exist or does not contain the “AC.db” file. You should probably create separate FolderItems to point to each of them so you can check their Exists property to ensure the folder and files are where you expect.

dim f as folderitem
dim ok as boolean
f=specialfolder.applicationdata.child("Accountancy Suite Data")
 if ok then 
end if

if not ok then 
    msgbox "no such database"
    exit sub
end if

This is off the top of my head so it might be “buggy” (or buggered???) use as example only… Not US centeric :smiley:

The syntax is incorrect. GetFolderItem does not accept a FolderItem. It wants a path. But it is not necessary here.

db.DatabaseFile = SpecialFolder.ApplicationData.Child("Accountancy Suite Data").Child("AC.db")

Edit: do it the way Dave suggests.

Thank you both!

I will do it the way Dave suggests.

So just to ensure I have understood correctly - GetFolderItem requires a path (as opposed to a FolderItem) meaning that:

f = GetFolderItem("Accountancy Suite").child("EULA.txt")

should be changed to:

f=SpecialFolder.ApplicationData.Child("Accountancy Suite Data").Child("EULA.txt")

Have I understood correctly?