Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

how do you create a browse button so the user can attach a file/image?Helpful Member!(3) 

cutestuff (TechnicalUser)
12 Oct 06 10:53
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...
Remou (TechnicalUser)
12 Oct 06 10:58
Depending on your version of Access, you may be able to use:
Application.FileDialog
Helpful Member!(3)  TheAceMan1 (Programmer)
15 Oct 06 10:41
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! .  .  .  .  .  .

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!

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