[AccessD] Adding Attachments

Mike and Doris Manning mikedorism at ntelos.net
Thu Mar 13 10:02:00 CST 2003


You have to do a FileCopy from the first selected location to the second
selected location in order to actually move the file.

Public Sub MoveFile(strOldPath As String, strOldName As String, _
                    strNewPath As String, strNewName As String)
                    
    On Error GoTo ErrorHandler
    
    Dim fso As FileSystemObject
    Dim strOldFile As String
            
    DoCmd.Hourglass True
    
    strOldFile = strOldPath & strOldName
    
    If Dir(strNewPath, vbDirectory) = "" Then
        Set fso = New FileSystemObject
        fso.CreateFolder strNewPath
    End If
    
    FileCopy strOldFile, strNewName
        
    DoCmd.Hourglass False
    
    Exit Sub
    
ErrorHandler:
    Call HandleErrors(Err, strMyName, "MoveFile")
End Sub

Doris Manning
Database Administrator
Hargrove Inc.
www.hargroveinc.com

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com] On Behalf Of Hollis,Virginia
Sent: Thursday, March 13, 2003 10:29 AM
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Adding Attachments


I have been playing around with the dialog to Save the file to a specified
folder. Tell me if anyone thinks this will work...
 
Use the Open file dialog so the user can select the file they need to
attach. Then the Save dialog box opens to the directory & folder where the
attachment needs to be saved.
 
Once they save the file it places the file name in the field 'attachments'
which is a hyperlink field.
 
Now, the problem... (there's always a catch)
 
How do I make the Save dialog box actually "Save" the file?! 
 
The Save dialog opens, and places the file name in the attachments field,
but it does not Save the file to the folder & directory.
 
Virginia

-----Original Message-----
From: Wortz, Charles [mailto:CWortz at tea.state.tx.us]
Sent: Wednesday, March 12, 2003 1:38 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Adding Attachments


Virginia,
 
If I was doing it I would add code that checks the path name and reject all
path names that start with a drive letter and only accept UNC path names.
Thus, the only drives on their computers that pass are shared drives.
 

Charles Wortz 
Software Development Division 
Texas Education Agency 
1701 N. Congress Ave 
Austin, TX 78701-1494 
512-463-9493 
CWortz at tea.state.tx.us 

-----Original Message-----
From: Hollis,Virginia [mailto:HollisVJ at pgdp.usec.com] 
Sent: Wednesday 2003 Mar 12 13:16
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Adding Attachments


Is there a way to have the attachment saved (moved?) to a common network
drive, or the directory the database is stored?
 
I got to thinking, there will be the user that will attach a file that is
stored on their computer, which obviously will make it unavailable to
everyone that needs the attachment.
 
Virginia
 
 

-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com]
Sent: Wednesday, March 12, 2003 7:09 AM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Adding Attachments



On my forms I have the text field beside a little button whose text is just
3 dots. The OnClick fires the code I posted. The user navigates to a file
and selects ok, then the code plugs the complete filename into the text
field (in this case BigImagePath).

 

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com] On Behalf Of Hollis,Virginia
Sent: March 11, 2003 12:34 PM
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] Adding Attachments

 

Ok, I found Sub TestGetFileName() in ADH.

 

You mentioned posting the results to a control. Do I need to have a button
on the form that opens the GetFileName? Then what transfers this file name
to the field?

 

Virginia

-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com]
Sent: Tuesday, March 11, 2003 10:20 AM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Adding Attachments

You don't need to use URLs if you don't want to. I use code from ADH that
calls the Windows API to open the GetFile dialog, then posts the result to a
control on my form, like so:

 

    With Me

        .BigImagePath = ahtCommonFileOpenSave()

    End With

 

To cohere to the licensing I cannot post said function or its API
declaration. Of course I could change all the variable names and the
function name and claim it as my own work, which is how I learned to
program, but now that I'm an old fart I don't do that any more.

 

(Fuller's Law #3: You start out a Young Turk and before you know it you're
an Old Fart.)

 

The function called above returns an absolute path, but given same and
knowledge of the app directory, it's a simple matter to replace the app path
with a relative reference. The Replace function does it in one line:

 

    Replace( strExp as String, strFind as String, strReplace as String )

 

HTH,

A.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030313/88586ec4/attachment-0001.html>


More information about the AccessD mailing list