INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Jobs from Indeed

how do you create a browse button so the user can attach a file/image?
3

how do you create a browse button so the user can attach a file/image?

how do you create a browse button so the user can attach a file/image?

(OP)
hi,

I have a data entry form where the user inputs information about a particular system. Sometimes though, these systems have images that need to be shown in the report.

I need to know if there is a way to create a "browse" button that the user can click and then search for a file to attach, then the path name of that file is stored in my table.

Please help.

Thank you so much...

RE: how do you create a browse button so the user can attach a file/image?

Depending on your version of Access, you may be able to use:
Application.FileDialog

RE: how do you create a browse button so the user can attach a file/image?

3
How are ya jenica024 . . .

You can also use the GetFilenameFromBrowse API.

Credit for the API goes to:
   KPD-Team 2001
   URL: http://www.allapi.net/

I've modified the code slightly so it can be called from any form.

In a new module in the modules window copy/paste the following:

CODE

Private Const VER_PLATFORM_WIN32_NT = 2
Private Type OSVERSIONINFO
   dwOSVersionInfoSize As Long
   dwMajorVersion As Long
   dwMinorVersion As Long
   dwBuildNumber As Long
   dwPlatformId As Long
   szCSDVersion As String * 128
End Type

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
                        (ByRef lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetFileNameFromBrowseW Lib "shell32" Alias "#63" _
                        (ByVal hwndOwner As Long, _
                         ByVal lpstrFile As Long, _
                         ByVal nMaxFile As Long, _
                         ByVal lpstrInitialDir As Long, _
                         ByVal lpstrDefExt As Long, _
                         ByVal lpstrFilter As Long, _
                         ByVal lpstrTitle As Long) As Long
Private Declare Function GetFileNameFromBrowseA Lib "shell32" Alias "#63" _
                        (ByVal hwndOwner As Long, _
                         ByVal lpstrFile As String, _
                         ByVal nMaxFile As Long, _
                         ByVal lpstrInitialDir As String, _
                         ByVal lpstrDefExt As String, _
                         ByVal lpstrFilter As String, _
                         ByVal lpstrTitle As String) As Long

Public Function BrowseFiles()
   Dim sSave As String
   
   sSave = Space(255)
   'If we're on WinNT, call the unicode version of the function
   If IsWinNT Then
      GetFileNameFromBrowseW Screen.ActiveForm.hwnd, _
                             StrPtr(sSave), _
                             255, _
                             StrPtr("c:\"), _
                             StrPtr("txt"), _
                             StrPtr("Text files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + _
                                    "All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)), _
                              StrPtr("The Title")
   'If we're not on WinNT, call the ANSI version of the function
   Else
      GetFileNameFromBrowseA Screen.ActiveForm.hwnd, _
                             sSave, _
                             255, _
                             "c:\", _
                             "txt", _
                             "All files (*.*)" + Chr$(0) + "*.*" + Chr$(0) + _
                             "Text files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0), _
                             "The Title"
   End If
   
   BrowseFiles = Trim(Replace(sSave, Chr$(0), " "))

End Function

Public Function IsWinNT() As Boolean
   Dim myOS As OSVERSIONINFO
   
   myOS.dwOSVersionInfoSize = Len(myOS)
   GetVersionEx myOS
   IsWinNT = (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT)

End Function
Then from any form calls would look like:

CODE

   Me!TextboxName = BrowseFiles()
   variable = BrowseFiles()
Cheers! . . .

See Ya! .  .  .  .  .  .

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close