Microsoft Access Developer Level 31 is 2 hours, 24 minutes long, and is available on my web site at [ Ссылка ]
TOPICS COVERED
Classic VB File Handling
Navigate Files & Folders
Dir, GetAttr, FileLen, MkDir, Kill, Name
ShellExecute to Open Files
FileCopy, FileExists, FolderExists
File, FolderNameFromPath
Compact Multiple Backend Files
Today's class continues our work with Classic VB File Handling. We will start out learning how to navigate between files and folders, select files with the file picker, launch files with ShellEx, copy files, create folders, and more. Then we'll learn how to automatically compact multiple back-end files. Lots to do in this class!
In Lesson 1, we start off with VB file and folder navigation, creating your own file browser, launching applications with the ShellExecute function, and using the standard Windows file picker.
In Lesson 2, we're going to learn how to copy files. We'll learn the FileCopy command. We'll create a central Images folder on your database server. We'll learn how to check to see if a file and folder exists. We'll create a folder with the MkDir command. We'll read the user's Windows system environment variables so we can determine where their User folder is and set that as the default file browse location. We'll store the last folder browsed in a TempVars variable. We'll learn how to separate filename and folder from the full path. We'll see how to get the length of a file with FileLen to check and make sure that the file copied 100% completely.
In Lesson 3, we will delete the old profile picture if a new one is selected with the Kill command. We'll ask the user first if it's OK before continuing, of course. We're not animals. We will verify the file has been deleted. We will timestamp new files as they are copied so that we don't run into duplicate filenames. We'll discuss error handling ramifications and best practices with File I/O functions. We'll see how to rename a file. I'll also talk about ChDrive and ChDir, although I almost never use them.
In Lesson 4, we will design a form to auto-compact multiple backend ACCDB files. If you have a split database and have multiple backend linked files, you'll be able to compact them all on a regular basis (like once a week) with a single click of a button. The database will allow you to pick your BE folder, loop thru the ACCDB files in that folder with a DIR, backup each file with a timestamp, compact it, and verify everything was done correctly. This one is a real time saver if, like me, you've got a dozen or so BE files.
Find out more at [ Ссылка ]
KEYWORDS
microsoft access, ms access, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #instruction, #learn, #lesson, #training, #database, file i/o, file input output, navigate files folders, file picker, shellex, copy file, create folder, compact multiple backends, filecopy, file exists, mkdir, environ, tempvars, filelen, kill
OUTLINE
01. Navigating Files & Folders (38:52)
File Management with Access
File Picker (PickFile)
Early vs. Late Binding
Use Numbers not Constants
Application.FileDialog
CurrentProject.Path
Dir Function
Loop Thru Files in Folder
vbNormal, vbDirectory
GetAttr Function
Move Thru Folders
InStrRev Function
ShellExecute to Open Files
FileLen Function
Format #,##0 Thousands Separator
02. Copying Files, Part 1 (32:34)
Learn the FileCopy Command
Browse and Pick File
Copy to Central Images Folder
Display on Customer Record
Add MyPicture Field to CustomerT
TempVars("PictureFolder") on Startup
Make Sure Folder Exists
FileExists, FolderExists Functions
Create Folder with MkDir
Button to Browse for Picture
Open a Command Prompt CMD
Windows Environment Variables SET
Environ("USERPROFILE")
Remember Last Browse Folder Location
FolderNameFromPath
FileNameFromPath
TempVars("LastBrowseFolder")
FileCopy Command
Put Image Control on Form
Check Size of Files
FileLen Function
03. Copying Files, Part 2 (20:18)
Delete Old Profile Picture if Exists
Kill Command
Verify that File was Deleted
Timestamp Filenames
File I/O Error Handling Concerns
Rename a File with Name Command
ChDrive, ChDir
04. Compact & Repair Backend Files (45:54)
Create Backend ACCDB Folder
Copy BE Files
Create BEFolder Field
Create PickFolder Function
Global Settings Table for BE Folder
Make FileList List Box
Loop Thru ACCDB Files in BE Folder
Use DIR for Loop
Load into FileList
Display FileLen in FileList
Loop Thru FileList
Create DoCompact Sub
Application.CompactRepair
DBEngine.CompactDatabase
Make Sure Backup Folder Exists
Copy Backups with DateTime Stamp
Perform Compact
Verify Dest File Exists
Delete Old File, Rename New One
Add Error Handling
Ещё видео!