Newsgroup: it.comp.appl.access
Titolo: Chiamata telefonica

Ciao newsgroup, sono un principiante di access, sono giorni che impazzisco
con questo problema
Dovrei mettere in un campo "nomefile" il nome di un file, mi potreste dire
come fare per inserire la ricerca e selezione come quella che per esempio
esce quando clicco su allega file di outlook.
Ho scaricato il database di esempio che c'č sul sitocomune, ma come ho detto
sono molto alle prime armi.
Se qualcuno mi butta giu una form, saro debitore per almeno 10 anni, e se mi
mette anche qualche spiegazione per 20.
Grazie in anticipo Nao

 Grazie in anticipo Nao
In un modulo del tuo database registra questo codice VBA:
' ******************************
Public Const OFN_FILEMUSTEXIST = &H1000
Public Const OFN_HIDEREADONLY = &H4
Public Const OFN_PATHMUSTEXIST = &H800
Public Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustomFilter 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
Public Declare Function GetOpenFileName Lib "comdlg32.dll" _
        Alias "GetOpenFileNameA" (lpofn As OPENFILENAME) As Long
'************************
'************************
Public Sub ShowFile(frm As Form, fb As OPENFILENAME)
    Dim fName As String
    Dim result As Long
    Dim path As String
    path = "C:\"
    With fb
        .lStructSize = Len(fb)
        .hwndOwner = frm.hWnd
        .hInstance = 0
        .lpstrFilter = "Tutti i File (*.*)" & vbNullChar & "*.*" &
vbNullChar
        .nMaxCustomFilter = 0
        .nFilterIndex = 1
        .lpstrFile = Space(256) & vbNullChar
        .nMaxFile = Len(.lpstrFile)
        .lpstrFileTitle = Space(256) & vbNullChar
        .nMaxFileTitle = Len(.lpstrFileTitle)
        .lpstrInitialDir = path & vbNullChar
        .lpstrTitle = "Scelta File" & vbNullChar
        .flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
        .nFileOffset = 0
        .nFileExtension = 0
        .lCustData = 0
        .lpfnHook = 0
    End With
    result = GetOpenFileName(fb)
    If result <> 0 Then
        fName = Left(fb.lpstrFile, InStr(fb.lpstrFile, vbNullChar) - 1)
    End If
End Sub
'***************************************
In una maschera inserisci una casella di testo non associata che si chiami
TxtFile.
Nella maschera inserisci anche un pulsante di comando e a fronte dell'evento
"Su clic" del pulsante di comando genera il seguente codice VBA:
    Dim fb As OPENFILENAME
    Dim fName As Variant
    Call ShowFile(Me, fb)
    fName = Left(fb.lpstrFile, InStr(fb.lpstrFile, vbNullChar) - 1)
    txtFile = fName
Non saprei che altro scriverti; se hai ancora dei proplemi rifatti vivo.
--
Roberto
---------------------------------------------
il Sito Comune di it.comp.appl.access:
http://www.sitocomune.com
---------------------------------------------

 > Ho scaricato il database di esempio che c'č sul sitocomune, ma come ho




pcodice per aprire finestra selezione file
Option Compare Database
Option Explicit
Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
            Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME)
As Long
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
Public Function cmdlg_file()
   Dim OpenFile As OPENFILENAME
   Dim lReturn As Long
   Dim sFilter As String
 
   OpenFile.lStructSize = Len(OpenFile)
   sFilter = "Immagini (*.wmf,*.bmp,*.jpg,*.tif)" & Chr(0) &
"*.wmf;*.bmp;*.jpg;*.tif" & Chr(0)
   OpenFile.hwndOwner = Application.hWndAccessApp
   OpenFile.lpstrFilter = sFilter
   OpenFile.nFilterIndex = 1
   OpenFile.lpstrFile = String(257, 0)
   OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
   OpenFile.lpstrFileTitle = OpenFile.lpstrFile
   OpenFile.nMaxFileTitle = OpenFile.nMaxFile
   OpenFile.lpstrInitialDir = "C:\"
   OpenFile.lpstrTitle = "Selezione"
   OpenFile.flags = 0
   lReturn = GetOpenFileName(OpenFile)
 
   If lReturn = 0 Then
      cmdlg_file = ""
 
   Else
      cmdlg_file = Left(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile,
Chr$(0)) - 1)
      Forms![tbl_Marca]![tbl_DESCRIZIONE Sottomaschera]!Immagine =
cmdlg_file
   End If
End Function
Saluti.
Emanuele.