Afbeelding toevoegen...

Status
Niet open voor verdere reacties.

MarlyNL

Gebruiker
Lid geworden
22 feb 2007
Berichten
16
ik heb nu gedeeltelijk een oplossing gevonden.
http://accdevel.tripod.com/imaging.htm
Dan die van access 200 heb ik gebruikt.
"C:\0-00-20-11.jpg" is het pad naar het plaatje (voor elk product anders)
Nu krijg ik hem ook afgebeeld zoals in de database in de link bij "frmImageFileDetail".
Ook heb ik de code erachter toegevoegd

PHP:
Option Compare Database
Option Explicit

Dim ysnSaveButtonClicked As Boolean
Private Sub cmdClose_Click()
' Purpose    : Close this form
' Parameters : None
' Created/Modified    : 5/23/99,
On Error GoTo Err_cmdClose_Click
    DoCmd.Close
Exit_cmdClose_Click:
    Exit Sub
Err_cmdClose_Click:
    MsgBox Err.Description
    Resume Exit_cmdClose_Click
    
End Sub
Private Sub Form_Open(Cancel As Integer)
' Purpose    : Set the name (of the external file) saved in the Record into the Image Control's
'               Picture property to display the picture
' Parameters : Cancel - if set to true, the Open Event is cancelled; used only if Error
' Created/Modified    : 8/24/99,
'On Error GoTo ErrHandler
    Me![imgTheImage].Picture = Me![txtImagePathAndFile]
Exit_Sub:
    Exit Sub
ErrHandler:
    MsgBox "Error " & Err.Number & " : " & Err.Description & " in Form_Open", vbExclamation, "Images in Access Example"
    Cancel = True
    Resume Exit_Sub
End Sub

PHP:
Tabel:

Materieel_code
Materieel_afbeelding

Allemaal tekst vakken verder geen specifieke opties...

Alleen nu laat die overal het zelfde plaatje zien...
Hoe kan ik dat veranderen?
Dus ieder product heeft een eigen plaatje (C:\0-00-20-11.jpg) en dan iedere een ander afbebeelding.
Als er geen afbeelding is moet die niks weergeven.
Hoe kan ik dat oplossen?
 
Laatst bewerkt:
Beetje moeilijk te reageren...

Sla je alleen links naar de plaatjes op of stop je alles in een BLOB?
Als je alleen inks ophaalt dan moet je de volgende code in je OnCurrent van je form zetten mits je die hebt gebound aan je datasource.
Code:
Me![imgTheImage].Picture = Me![txtImagePathAndFile]
Misschien ook nog met een LoadPicture statement
Code:
Me![imgTheImage].Picture = LoadPicture(Me![txtImagePathAndFile])
Als er geen pad is, dus geen plaatje dan ziet je code er als volgt uit
Code:
If Len(Nz(Me![txtImagePathAndFile]) > 0 Then Me![imgTheImage].Picture = LoadPicture(Me![txtImagePathAndFile])
Als je je plaatje als BLOB hebt opgeslagen dan wordt deze automatisch getoond. Als dat het geval is dan is er iets anders aan de hand.

Succes!

PS BLOB is een Binary Large Object.
 
Laatst bewerkt:
Ik heb het probleem opgelost.
Op een andere manier.
Hoe dat weet ik zo niet precies maar het werkt goed.
 
Met hulp van iemand is het gelukt ik kon alleen niet zien hoe die dat pcies deed...
 
Ben nog steeds benieuwd...

Ben jij niet benieuwd? Dit is een leer moment!
 
Ik heb het een beetje gekeken net.
In de tabel Materieel is een (rij of kolom) bijgekomen met de naam Afbeelding.
Hier in staat de server naam: \\10.1.0.21\0-00-20-30.JPG
Deze word weer naar voren gehaald door een text vak.
Dan zit er een VBA code achter:
PHP:
Option Compare Database
Option Explicit

Private Sub Form_AfterUpdate()
    On Error Resume Next
    If IsNull(Me.Lokatie_Afbeelding.Value) Then
        Me.Kader_Foto.Visible = False
        Me.Lokatie_Afbeelding.Visible = False
    Else
        Me.Kader_Foto.Visible = True
        Me.Lokatie_Afbeelding.Visible = True
        Me.Kader_Foto.Picture = Me.Lokatie_Afbeelding.Value
    End If
End Sub

Private Sub Form_Current()
    On Error Resume Next
    If IsNull(Me.Lokatie_Afbeelding.Value) Then
        Me.Kader_Foto.Visible = False
        Me.Lokatie_Afbeelding.Visible = False
    Else
        Me.Kader_Foto.Visible = True
        Me.Lokatie_Afbeelding.Visible = True
        Me.Kader_Foto.Picture = Me.Lokatie_Afbeelding.Value
    End If
End Sub

En nog een module word er gebruikt.
Heb er 2 en weet niet welke er gebruikt word.

mod_Database
PHP:
Option Compare Database
Option Explicit

Function EigenschapWijzigen(strNaamEigenschap As String, varTypeEigenschap As Variant, varWaardeEigenschap As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conEigenschapNietGevondenFout = 3270

    Set dbs = CurrentDb
    On Error GoTo Wijzigen_Err
    dbs.Properties(strNaamEigenschap) = varWaardeEigenschap
    EigenschapWijzigen = True

Wijzigen_Bye:
    Exit Function

Wijzigen_Err:
    If Err = conEigenschapNietGevondenFout Then    ' Eigenschap niet gevonden.
        Set prp = dbs.CreateProperty(strNaamEigenschap, _
            varTypeEigenschap, varWaardeEigenschap)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Onbekende fout.
        EigenschapWijzigen = False
        Resume Wijzigen_Bye
    End If
End Function

mod_FormDialog
PHP:
Option Compare Database
Option Explicit

' Public types are defined here.
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 Type BROWSEINFO
    hWndOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlags As Long
    lpfn As Long
    lParam As Long
    iImage As Long
End Type

Public Type FileTime
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type

Public Type WIN32_FIND_DATA
    dwFileAttributes As Long
    ftCreationTime As FileTime
    ftLastAccessTime As FileTime
    ftLastWriteTime As FileTime
    nFileSizeHigh As Long
    nFileSizeLow As Long
    dwReserved0 As Long
    dwReserved1 As Long
    cFileName As String * 260
    cAlternate As String * 14
End Type

Public Type STARTUPINFO
    cb As Long
    lpReserved As String
    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Long
    cbReserved2 As Long
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type

Public Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessId As Long
    dwThreadID As Long
End Type

' Public constants are defined here.
Public Const OFN_ALLOWMULTISELECT As Long = &H200
Public Const OFN_CREATEPROMPT As Long = &H2000
Public Const OFN_ENABLEHOOK As Long = &H20
Public Const OFN_ENABLETEMPLATE As Long = &H40
Public Const OFN_ENABLETEMPLATEHANDLE As Long = &H80
Public Const OFN_EXPLORER As Long = &H80000
Public Const OFN_EXTENSIONDIFFERENT As Long = &H400
Public Const OFN_FILEMUSTEXIST As Long = &H1000
Public Const OFN_HIDEREADONLY As Long = &H4
Public Const OFN_LONGNAMES As Long = &H200000
Public Const OFN_NOCHANGEDIR As Long = &H8
Public Const OFN_NODEREFERENCELINKS As Long = &H100000
Public Const OFN_NOLONGNAMES As Long = &H40000
Public Const OFN_NONETWORKBUTTON As Long = &H20000
Public Const OFN_NOREADONLYRETURN As Long = &H8000&
Public Const OFN_NOTESTFILECREATE As Long = &H10000
Public Const OFN_NOVALIDATE As Long = &H100
Public Const OFN_OVERWRITEPROMPT As Long = &H2
Public Const OFN_PATHMUSTEXIST As Long = &H800
Public Const OFN_READONLY As Long = &H1
Public Const OFN_SHAREAWARE As Long = &H4000
Public Const OFN_SHAREFALLTHROUGH As Long = 2
Public Const OFN_SHAREWARN As Long = 0
Public Const OFN_SHARENOWARN As Long = 1
Public Const OFN_SHOWHELP As Long = &H10

Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (lpofn As OPENFILENAME) As Long
Public Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (lpofn As OPENFILENAME) As Long


Public Function Dialogbox(ByVal Title As String, Optional ByVal Filter As String = "all", Optional ByVal Style As String = "open", Optional ByVal deffile As String, Optional ByVal InitialDir As String = "C:\", Optional ByVal Multiple As Boolean = False) As String
' This pops an open or save as file dialog box with the passed in title and filtered according to the (optional)
' passed in extension with the optional passed in default filename displayed.  The selected filename is returned.
    
    Dim filebox As OPENFILENAME  ' open file dialog structure
    Dim Result As Long           ' result of opening the dialog
    Dim filter_num As Integer    ' the number of the default filter
    
    Select Case Filter
    
        Case "txt"
        
            filter_num = 1
            
        Case "xls"
        
            filter_num = 2
        
        Case "mdb"
        
            filter_num = 3
            
        Case "doc"
        
            filter_num = 4
            
        Case "spl"
        
            filter_num = 5
        
        Case "all"
        
            filter_num = 6
            
        Case Else
        
            filter_num = 6
        
    End Select
    
    ' Configure how the dialog box will look
    With filebox
        ' Size of the structure.
        .lStructSize = Len(filebox)
        ' Handle to window opening the dialog.
        '.hwndOwner = 333
        ' Handle to calling instance (not needed).
        '.hInstance = 0
        ' File filters to make available.
        .lpstrFilter = "Text Files (*.txt)" & vbNullChar & "*.txt" & vbNullChar & _
            "Microsoft Excel (*.xls)" & vbNullChar & "*.xls" & vbNullChar & _
            "Microsoft Access (*.mdb)" & vbNullChar & "*.mdb" & vbNullChar & _
            "Microsoft Word (*.doc)" & vbNullChar & "*.doc" & vbNullChar & _
            "Spool files (*.spl)" & vbNullChar & "*.spl" & vbNullChar & _
            "All Files (*.*)" & vbNullChar & "*.*" & vbNullChar & vbNullChar
        '.lpstrCustomFilter is ignored -- unused string
        .nMaxCustomFilter = 0
        ' Default filter based on passed in extension.
        .nFilterIndex = filter_num
        ' No default filename.  Also make room for received
        ' path and filename of the user's selection.
        .lpstrFile = deffile & Space(1024) & vbNullChar
        .nMaxFile = Len(.lpstrFile)
        ' Make room for filename of the user's selection.
        .lpstrFileTitle = Space(1024) & vbNullChar
        .nMaxFileTitle = Len(.lpstrFileTitle)
        ' Initial directory is initialdir.
        .lpstrInitialDir = InitialDir & vbNullChar
        ' Title of file dialog.
        .lpstrTitle = Title & vbNullChar
        
        If Style = "saveas" Then
        
            ' Warn if an existing file is selected.
            .flags = OFN_PATHMUSTEXIST Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
        
        ElseIf (Style = "open" And Multiple = False) Then
        
            ' The path and file must exist.
            .flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
        
        ElseIf (Style = "open" And Multiple = True) Then
        
            ' The path and file must exist and multiple selection is available.
            .flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST Or OFN_ALLOWMULTISELECT Or OFN_EXPLORER
        
        End If
        ' The rest of the options aren't needed.
        '.nFileOffset = 0
        '.nFileExtension = 0
        If Filter <> "all" Then .lpstrDefExt = Filter
        '.lCustData = 0
        '.lpfnHook = 0
        '.lpTemplateName is ignored -- unused string
    End With
    
    ' Display the dialog box.
    If Style = "open" Then
    
        Result = GetOpenFileName(filebox)
        
    ElseIf Style = "saveas" Then
    
        Result = GetSaveFileName(filebox)
    
    End If
    
    If Result <> 0 Then
       
        If (Style = "open" And Multiple = True) Then
        
            Dialogbox = filebox.lpstrFile
        
        Else
        
            Dialogbox = Left(filebox.lpstrFile, InStr(filebox.lpstrFile, vbNullChar) - 1)
        
        End If
        
    End If
    
End Function

En hoe en wat verder precies ben ik nog niet achter.
Dat ga ik nog uitzoeken, als ik dan meer weet hoor je het wel.
 
Ik heb het een beetje gekeken net.
In de tabel Materieel is een (rij of kolom) bijgekomen met de naam Afbeelding.
Hier in staat de server naam: \\10.1.0.21\0-00-20-30.JPG
Deze word weer naar voren gehaald door een text vak.
Dan zit er een VBA code achter:
PHP:
Option Compare Database
Option Explicit

Private Sub Form_AfterUpdate()
    On Error Resume Next
    If IsNull(Me.Lokatie_Afbeelding.Value) Then
        Me.Kader_Foto.Visible = False
        Me.Lokatie_Afbeelding.Visible = False
    Else
        Me.Kader_Foto.Visible = True
        Me.Lokatie_Afbeelding.Visible = True
        Me.Kader_Foto.Picture = Me.Lokatie_Afbeelding.Value
    End If
End Sub

Private Sub Form_Current()
    On Error Resume Next
    If IsNull(Me.Lokatie_Afbeelding.Value) Then
        Me.Kader_Foto.Visible = False
        Me.Lokatie_Afbeelding.Visible = False
    Else
        Me.Kader_Foto.Visible = True
        Me.Lokatie_Afbeelding.Visible = True
        Me.Kader_Foto.Picture = Me.Lokatie_Afbeelding.Value
    End If
End Sub

Voor iedere afbeelding wordt een veld gevuld die Lokatie_Afbeelding heet.
Als deze ongelijk is aan Null dan wordt de picture property van het Kader_Photo object gevuld met die waarde. Als die Null is dan wordt de afbeelding invisible gemaakt.
zoals ik al voorstelde in mijn eerste reactie.

De rest van de modules worden voor dit probleem niet gebruikt. De eerste mod_Database voegt een property toe aan je database en de tweede zorgt voor een dialoog schermpje waarin je filename op kan geven.

Bedankt!
Weer wat geleerd. Je hoeft dus geen LoadPicture te gebruiken.

Enjoy!
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan