Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    1

    Unanswered: Images in a Tab Control

    I have a small problem that I would be grateful if anybody could help. I am trying to handle and show images in a form but there is a small problem. I have used the code and procedure described here http://dbforums.com/arch/112/2002/12/640093. My problem is that I am trying to do that on the first page of a tab control and it doesn't seem to be working. One reason could be that I don't have the option "Current" for Tab Page as there is for the form Private Sub Form_Current() and hence i can't get it to work.

    Any ideas?
    Thanks in advance.

  2. #2
    Join Date
    Sep 2003
    Location
    Gloucester
    Posts
    28
    I have done something similar a few years ago - in my case I needed to view a number of images (40K plus) associated with (17K plus) records.

    I created two tables - I will only list the minimum of fields you should require to get you up and running.

    TRecords

    RecID Autonumber and Primary Key
    Record Text - holds document exhibit title
    PageStart Number - Holds start page
    PageEnd Number - Holds End Page
    NrPages Number - Holds total nr of pages in this document

    TImageLink

    RecID Number - Foreign Key to RecID in TRecords
    Page Number - line entry for each page in Document
    Image Text - File path for image and file type


    Next step was to construct the opening form -

    This contained some 8 tabs to, required to show various processes that the documents had gone through. Initial form datasource comes from a query based on TRecords

    This was complemented by a sub form "Image Subform" that presented the first page of the document and the user is allowed to proceed to other pages via the nav buttons.

    Properties page, Data tab of the Image subform
    Source Object = Image Subform
    Link Child Fields = RecID
    Link Master Fields = RecID
    Enabled = Yes
    Locked = No

    Properties, Event Tab, On Current

    Private Sub Form_Current()
    Dim RetValue
    ' Whenever we change the current record, we load a new image.
    ' If the image does not exist, or is not of a displayable format,
    ' we trap the error message panel to avoid displaying a confusing
    ' message to the user.
    On Error GoTo Error_BadImage
    Image4.Picture = [image].Value
    Exit Sub
    Error_BadImage:
    ' Include code here to handle Image Errors.
    'RetValue = MsgBox("The current image could not be displayed.", vbOKOnly)
    Image4.Picture = "c:\Alison\Default.tif"
    Exit Sub
    End Sub

    In the DETAIL section of the subform place twoTextboxes

    1 Name = RecID
    Control source = RecID
    2 Name = Image
    Control source = Image


    When you open the image subform you should be able to see the default image - dont forget to make make one.

    Switch to design mode and select the image - right click - properties - Event tab - on click

    Private Sub Image4_Click()
    Dim RetValue
    ' When the user clicks on the image, we launch the image editor
    ' software, which allows the addition of annotation to the image.
    ' We trap any errors to attempt to give a more helpfull message.
    On Error GoTo Err_Image_Click
    Call Shell("C:\Program Files\Windows NT\Accessories\ImageVue\WangImg.exe " & [laptop image].Value, 1)
    Exit Sub
    Err_Image_Click:
    RetValue = MsgBox("Unable to open image file. Maybe it's already open.", vbOKOnly)
    Exit Sub
    End Sub

    On Double click

    Private Sub Image4_DblClick(Cancel As Integer)
    Dim RetValue
    ' When the user double clicks on the image, we launch the image editor
    ' software, which allows the addition of annotation to the image.
    ' We trap any errors to attempt to give a more helpfull message.
    On Error GoTo Err_Image_Click
    Call Shell("C:\Program Files\Windows NT\Accessories\ImageVue\WangImg.exe " & [laptop image].Value, 1)
    Exit Sub
    Err_Image_Click:
    RetValue = MsgBox("Unable to open image file. Maybe it's already open.", vbOKOnly)
    Exit Sub

    End Sub


    Initially I had the image displaying on each tab in my main form but this became a little time consuming and the users were prone to jumping to different tabs before the images had loaded resulting in some failure.

    To get round this I showed the image on the first tab and on subsequent tabs place a button that showed the image as required

    Private Sub connect_to_image_Click()
    On Error GoTo Err_connect_to_image_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Image subform"

    stLinkCriteria = "[RecID]=" & Me![RecID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_connect_to_image_Click:
    Exit Sub

    Err_connect_to_image_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_connect_to_image_Click

    End Sub



    Hope this helps - bit of a long one I know
    Last edited by Jumper; 10-16-03 at 10:31.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •