Relink Backend Files, File System Object 1 & 2
Today's class begins with automatically relinking back-end files (with VBA, of course). We'll start out reviewing the Linked Table Manager, and then we'll learn how to determine whether or not our back-end file needs to be relinked. If so, we will relink a single back-end file using VBA. Then we'll learn how to relink multiple back-end files. I'll also cover how to relink to ODBC sources including SQL Server (even online databases).
Then, we'll learn about the File System Object to work with files and folders. We started learning about File I/O in Developer 30. Today we'll continue with a more powerful method. We'll learn about Early v. Late Binding of objects, how to create a folder, loop to create multiple folders, determine the size of a folder (and subfolders/files) and how to read and change the properties and attributes of folders and files.
In Lesson 1, we will learn how to use the Linked Table Manager to relink your tables just in case your back-end database file has been moved or renamed. This and lesson 2 are free bonus lessons which don't count towards the hour for this class. Yes, we have covered this material before in earlier lessons, but it's a good review before lessons 2 and 3 which get into more advanced material.
In Lesson 2, we will learn how to use VBA to automatically relink to the back-end file. The database will recognize that the tables are missing, prompt you for the new back-end file location, and then relink it for you. We will use the TableDefs collection and my PickFile function. This solution will work for a single back-end file.
In Lesson 3, we will learn how to automatically relink to multiple back-end files. We'll loop through all of the tables in the database and see if each table is linked. If not, we will prompt the user for the location, relink it, and continue on to the next table.
In Lesson 4, we will learn how to automatically relink ODBC tables, including those linked to SQL Server (both local and online databases).
In Lesson 5, we will learn how to work with the File System Object. We'll talk about Early vs. Late Binding, the Windows Script Host, how to find the database's folder with CurrentProject.Path, how to create a folder, and how to loop to create multiple subfolders.
In Lesson 6, we are continuing with the File System Object. We'll learn how to use GetFolder to create a folder object that we can work with to get it's properties and collections. We'll learn about the SubFolders collection, file and folder properties, how to determine the size of a folder (and all of its subfolders and files), read the attributes of a file/folder, and how to change those attributes.
Enroll now so that you can watch these lessons, learn with us, post questions, and more.
Please feel free to post your questions or comments below. Thanks.
You may want to read these articles from the 599CD News: