artful at rogers.com
artful at rogers.com
Sat Sep 2 14:00:51 CDT 2006
One thing that you could do fairly easily is create a table in the BE with exactly one row, and call it SysParameters or somesuch. Place a column in said table that would house the path to the backup instrument. Given that you have two variables, one indicating the name of the FE and the other indicating the path to the backup, you might want to add both columns to the SysParameters table. There are several schools of thought as to how to retrieve these values from the SysParameters table. A colleague of mine likes to drop some invisible controls on his Switchboard form, and draw the values into said controls using Dlookup(). I am not a fan of this approach; I prefer to use static functions (which are functions that retain their value between calls). JWC will tell you that the best approach is a class. Ultimately, it doesn't matter which path you select. The goal is to move the specifics out of your code and into a table. You could even fancy this up by running some code in the startup that looks in this table to see if these values are null, and if so it presents a form asking the user to name these objects (the FE and the target BU path). Your code ultimately needs to anticipate every possible drive/dir combination. For example, my main squeeze has 3 USB ports and depending on the day, who knows what's plugged into which port? Could be a digital camera, could be one of my two memory sticks. And conceivably I could be pointing to my DVD writer, which happens not to be on my main squeeze but instead is mapped. That's why I like the SysParameters approach. The user can set her situation up and be done with it, and if she happens to acquire a new DVD writer, she just visits this form, fixes the pointer and that is that. hth. Arthur ----- Original Message ---- From: Chris Enright <cclenright at yahoo.com> To: Access Developers discussion and problem solving <accessd at databaseadvisors.com> Sent: Saturday, September 2, 2006 2:04:48 PM Subject: [AccessD] Where is the Zip Drive? The little I know about VBA I got from this site. Every day I read every email! Eighty percent goes right over my head! But the little I have understood from AccessD makes me a living. J I have a program that the customer loves. He keeps opening new branches and, because he is slightly computer literate (and therefore dangerous), he happily installs FE and, a BE with blank tables, on each new PC. Unfortunately, the people who supply the PCs to him configure them differently each time they supply one. My program is designed so that, at close down, it will backup the BE to an Iola Zip Disk. This is normally E:. (Based on A: Floppy, B: (showing your age), C: Hard Disk, D: CD/DVD.) However, sometimes there seem to be all sorts of odd drives, even phantom disk partitions and the Zip Drive isnt where I programmed it. The customer LOVES going in to my FE and sorting it out! Inevitably I then spend hours (because he didnt tell me what he had done) tracking down a problem on a new installation. Below is my, very crude, (please dont laugh, it normally works), backup function. Could someone please correct it, either to the list or offline, so that it will detect where the Zip Disk is? TIA Chris {Oh I am embarrassed about showing my code to you lot} ---------------------------------------------------------------------------------- Private Function Backup() Dim strNewDBName As String Dim strOldDbName As String Dim fso Dim file As String Dim msg As String On Error GoTo Err_Backup DoCmd.Hourglass True ' copy database strOldDbName = "C:\Startan\Startan BE.mdb" strNewDBName = "D:\BuExp.mdb" FileCopy strOldDbName, strNewDBName ' if a previous backup exists then delete it file = "D:\StartanBU.mdb" Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(file) Then fso.DeleteFile file, True End If ' rename backup database Name strNewDBName As file DoCmd.Hourglass False Exit_Backup: Exit Function Err_Backup: msg = "Make sure the Zip Disk is in the computer " '& Chr(10) msg = msg & "and that the drive lights have stopped flashing " msg = msg & "and then press Enter" MsgBox msg Resume End Function Still blushing, going for a drink!! Chris --------------------------------- Stay in the know. Pulse on the new Yahoo.com. Check it out. -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com