mrtauntaun
MIS
Hi. I have an inventory database, and I would like to create a button to import a small .jpg or .gif into the record. Thusly, whenever the record is called up, there is the visual record of the item. How can I do this? Thanx!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=blue]
'-----------------------------------------------------------------------------
Private Type OPENFILENAME
lStructSize As Long
hWndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public Function BrowseForFile(Optional ByVal strFileNameIn _
As String = "", Optional strDialogTitle _
As String = "Name of File to Open", _
Optional strFileType As String, _
Optional strExtension As String)
Dim lngReturn As Long
Dim intLocNull As Integer
Dim strTemp As String
Dim ofnFileInfo As OPENFILENAME
Dim strInitialDir As String
Dim strFilename As String
'-- if a file path passed in with the name,
'-- parse it and split it off.
If InStr(strFileNameIn, "\") <> 0 Then
strInitialDir = Left(strFileNameIn, InStrRev(strFileNameIn, "\"))
strFilename = Left(Mid$(strFileNameIn, _
InStrRev(strFileNameIn, "\") + 1) & _
String(256, 0), 256)
Else
strInitialDir = CurrentProject.Path
strFilename = Left(strFileNameIn & String(256, 0), 256)
End If
With ofnFileInfo
.lStructSize = Len(ofnFileInfo)
.lpstrFile = strFilename
.lpstrFileTitle = String(256, 0)
.lpstrInitialDir = strInitialDir
.hWndOwner = Application.hWndAccessApp
If strFileType <> "" And strExtension <> "" Then
.lpstrFilter = strFileType & " " & "(*." & strExtension & ")" & Chr(0) & _
"*." & UCase(strExtension) & Chr(0)
Else
.lpstrFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0)
End If
.nFilterIndex = 1
.nMaxFile = Len(strFilename)
.nMaxFileTitle = ofnFileInfo.nMaxFile
.lpstrTitle = strDialogTitle
'.flags = cdlOFNFileMustExist Or cdlOFNHideReadOnly Or _
cdlOFNNoChangeDir
.hInstance = 0
.lpstrCustomFilter = String(255, 0)
.nMaxCustFilter = 255
.lpfnHook = 0
End With
lngReturn = GetOpenFileName(ofnFileInfo)
If lngReturn = 0 Then
strTemp = ""
Else
'-- Trim off any null string
strTemp = Trim(ofnFileInfo.lpstrFile)
intLocNull = InStr(strTemp, Chr(0))
If intLocNull Then
strTemp = Left(strTemp, intLocNull - 1)
End If
End If
BrowseForFile = strTemp
End Function
'-----------------------------------------------------------------------------
[/color]