placing file selected in opendialog box into text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • munkee
    Contributor
    • Feb 2010
    • 374

    placing file selected in opendialog box into text box

    Hi all,

    I am using some cutdown code which I have changed around to allow me to select a file to be attached to an email within my database. The code is as follows:

    Code:
    Function EmailAttach()
        Dim strFilter As String
        Dim lngFlags As Long
        Dim strInputFileName As String
        
        strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
                        "*.MDA;*.MDB")
        strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
        strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
        strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.pdf)", "*.PDF")
        strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
        strInputFileName = ahtCommonFileOpenSave(InitialDir:="C:\", _
            Filter:=strFilter, FilterIndex:=3, flags:=lngFlags, _
            DialogTitle:="Select attachment!
        
    End Function
    However, I am utterly useless at working with functions. How do I get the filename/path selected to be input into a textbox that I specify.

    I have tried changing strInputFileNam e = to me.mail_attache ment_path.value with no luck.

    I am calling the function from a button where I have also tried:

    Me.mail_attache ment_path.value = EmailAttach with no luck.
  • munkee
    Contributor
    • Feb 2010
    • 374

    #2
    Solved it!

    Code:
    Private Sub Command34_Click()
    Me.Mail_Attachment_Path = EmailAttach()
    End Sub
    Code:
    Function EmailAttach() As String
        Dim strFilter As String
        Dim lngFlags As Long
        Dim strInputFileName As String
        
        strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
                        "*.MDA;*.MDB")
        strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
        strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
        strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.pdf)", "*.PDF")
        strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
        EmailAttach = ahtCommonFileOpenSave(InitialDir:="C:\", _
            Filter:=strFilter, FilterIndex:=3, flags:=lngFlags, _
            DialogTitle:="Email attachment
        
      
    End Function

    Comment

    Working...