Access 2010 - Cum sa afiseze imagini dintr-ul folder in raport

Ce este nou in Microsoft Access 2010?
Informatii despre cum se utilizeaza Microsoft Access 2010.
Baze de date, Interogari, Formulare, Rapoarte, etc
SharQue99
Mesaje: 72
Membru din: Vin Noi 02, 2012 3:06 pm

Access 2010 - Cum sa afiseze imagini dintr-ul folder in raport

Mesaj de SharQue99 » Dum Iul 21, 2019 7:34 pm

Salutare,

Vin catre voi cu rugamintea sa ma ajutati cu o idee referitoare la situatia urmatoare: Trebuie sa fac pentru la serviciu o baza de date in access, ce pare simpla dar imi tot da batai de cap.

Aceasta baza de date trebuie sa aiba:

- tbl_produse: id_produs, nume_produs,cod produs


In raport "rp_produse" doresc sa imi apara produsele iar in dreptul lor poza ce este salvata intr-un alt folder cu denumirea=cod_produs;
Am tot cautat pe internet si am gasit urmatorul link: " https://support.microsoft.com/en-us/hel ... data-acces ".
Am creat tabelul, am creat modulul, problema vine la urmatorele, si nu inteleg ce vrea sa zica:

"Open the tblImage table in Datasheet view, and then add the path and name of a bitmap file to each record. The following table of examples shows how the records might look:

--------------------------------------------------------------
| Type | Example |
--------------------------------------------------------------
| Absolute (Local) | C:\Windows\Zapotec.bmp |
| Absolute (UNC Path) | \\Servername\sharename\Zapotec.bmp |
| Relative | Zapotec.bmp |
--------------------------------------------------------------

Using the custom function in a report

Create the following new report that is based on the ImageTable table.

Report: rptImage
----------------------
Caption: Image Report
RecordSource: tblImage

Image Control
---------------------------------
Name: ImageFrame
Picture: "C:\Windows\Zapotec.bmp"

Text box
----------------------
Name: txtImageID
ControlSource: ImageID

Text box
---------------------------
Name: txtImageName
ControlSource: txtImageName

Text box
---------------------------
Name: txtImageNote
ControlSource: <Blank>

NOTE: If you do not want the path to appear in the report, you can set the Visible property of the txtImageName control to False.
On the View menu, click Code, and then paste or type the following code:
Option Compare Database
Option Explicit

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me!txtImageNote = DisplayImage(Me!ImageFrame, Me!txtImageName)
End Sub
Open the rptImage report in print preview. Note that the report displays the corresponding bitmap for each record. If the txtImageName field is blank or if the image cannot be found, you receive appropriate messages instead of the image frame."



Ma puteti ajuta, va rog cu un sfat ?


Va multumesc,
Nu aveţi permisiunea de a vizualiza fişierele ataşate acestui mesaj.

Dr.Windows
Moderator
Moderator
Mesaje: 4570
Membru din: Vin Iul 31, 2009 7:32 am

Re: Access 2010 - Cum sa afiseze imagini dintr-ul folder in raport

Mesaj de Dr.Windows » Sâm Aug 17, 2019 8:13 am

Salut!

Pe baza instructiunilor Microsoft postate de tine, am modificat putin codul in asa fel incat sa nu mai fie o functie, daca nu este necesar sa afisezi textul "Nu a fost gasita imaginea", in schimb va afisa o imagine "default". In plus in variabila strImgBasePath ar trebui pusa calea relativa la baza de date unde sunt stocate imaginile.

Cod: Selectaţi tot

Public Sub DisplayImage(ctlImageControl As Control, strImageName As Variant)
On Error GoTo Err_DisplayImage

Dim strImgBasePath As String
Dim strDatabasePath As String

strImgBasePath = "Imagini\"

With ctlImageControl
    If IsNull(strImageName) Then
        strImageName = "NoImage"
    Else
        strDatabasePath = CurrentProject.Path & "\"
        strImageName = strDatabasePath & strImgBasePath & strImageName & ".jpg"
        .Picture = strImageName
    End If
End With
    
Exit_DisplayImage:
    Exit Sub

Err_DisplayImage:
    Select Case Err.Number
        Case 2220       ' Can't find the picture.
            strImageName = strDatabasePath & strImgBasePath & "NoImage.jpg"
            Resume 0
        Case Else       ' Some other error.
            MsgBox Err.Number & " " & Err.Description
            Resume Exit_DisplayImage:
    End Select
End Sub
Apoi doar am creat formularul care foloseste codul de afisare in cateva evenimente cheie pentru a putea afisa imaginea (pentru ca am modificat codul initial si modul de apelare se modifica fata de articolul Microsoft):

Cod: Selectaţi tot

Private Sub Form_AfterUpdate()
    CallDisplayImage
End Sub

Private Sub Form_Current()
    CallDisplayImage
End Sub

Private Sub txtImageName_AfterUpdate()
    CallDisplayImage
End Sub

Private Sub CallDisplayImage()
    Call DisplayImage(Me!imgFrame, Me!txtImageName)
End Sub
Pentru detalii vezi baza de date atasata, iar pentru si mai multe detalii vezi si un articol mai vechi: Re: inserare poze in BD
Nu aveţi permisiunea de a vizualiza fişierele ataşate acestui mesaj.

Scrie răspuns

Înapoi la “Intrebari despre Access 2010”