Display images on a running form

D

Doekoe

I have table with information fields which belongs to images stored on
the network. So in my table I also have a field with the path to each
image. Now we display every record in single modus, but if you look
for a specified image, it is hard to search. Now I want to display the
form showing all records at once (running form mode...?), but the
problem is that is shows the same image (the first one) at all
records.

I do not want to have the images in the table (database), but want to
use the path because there are a lot of images.

Is there a way that I can use the running form mode and display the
proper picture at each record.

Thanks in advance.

Dirk
 
O

OldPro

I have table with information fields which belongs to images stored on
the network. So in my table I also have a field with the path to each
image. Now we display every record in single modus, but if you look
for a specified image, it is hard to search. Now I want to display the
form showing all records at once (running form mode...?), but the
problem is that is shows the same image (the first one) at all
records.

I do not want to have the images in the table (database), but want to
use the path because there are a lot of images.

Is there a way that I can use the running form mode and display the
proper picture at each record.

Thanks in advance.

Dirk

Do you mean Continuous Forms? I don't believe it will work for this.
You would be better off making a custom form. Let me know if this is
the way you want to go. If you need details, I can outline the
process.
 
D

Doekoe

Do you mean Continuous Forms? I don't believe it will work for this.
You would be better off making a custom form. Let me know if this is
the way you want to go. If you need details, I can outline the
process.- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Yes, I mean a continouos form. I found the right word later. I would
appreciate some help on how to setup a custom form.

Thanks,

Dirk
 
O

OldPro

Yes, I mean a continouos form. I found the right word later. I would
appreciate some help on how to setup a custom form.

Thanks,

Dirk- Hide quoted text -

- Show quoted text -

You will need to come up with an arraingement of labels and the image
control to represent one record, and repeat this arrangement maybe 8
times going down the screen. Custom scrollbars can be added that will
allow the user to access all of the records. Use labels for
everything except the images. Name the labels after the fields they
represent and add a number to represent their sequence in the on-
screen grid. For example the first set of labels might be named
lblFileName1, lblRevDate1, lblPath1, and imgArtwork1, the second set
lblFileName2, lblRevDate2, lblPath2, and imgArtwork2. This way each
label can be referenced with something like Me("lblFileName" &
GridRowNo).

The scrollbar can be made with a few labels and a command button. Use
Windows Paint to create a couple of up and down arrow bitmaps. The
command button is vital, although it is set to transparent. It
intercepts all of the mouse events. Using these events a label can be
programmed to move as a slide bar. For this to work, the command
button must be topmost in the Z order. The slide label which is
visible operates just below the command button. The command button
must be as long as the label that will represent the scrollbar tray,
and be positioned exactly over it. Obviously the tray label will be
lowest in the z order, then the slide label, and finally the
transparent command button.

Labels cannot be used for editing. If you need to use this screen for
editing the records, then use an invisible textbox that is sized,
positioned over a label and made visible through code when a user
clicks on that label.

Use a variable called RecordInTopRow or something like that to hold
the number of the record currently residing in the top row of the
grid. This needs to be declared at form level. The scroll events
(mouse move events on the transparent command button) will modify this
number. A function needs to be written to take this number and
display a screenful of records. Concrete examples of all of this can
be found by searching the use-nets (google groups) with my name
(OldPro). If you need further assistance on any part of this, let me
know and I will go into more detail in a later message.
 
D

Doekoe

You will need to come up with an arraingement of labels and the image
control to represent one record, and repeat this arrangement maybe 8
times going down the screen. Custom scrollbars can be added that will
allow the user to access all of the records. Use labels for
everything except the images. Name the labels after the fields they
represent and add a number to represent their sequence in the on-
screen grid. For example the first set of labels might be named
lblFileName1, lblRevDate1, lblPath1, and imgArtwork1, the second set
lblFileName2, lblRevDate2, lblPath2, and imgArtwork2. This way each
label can be referenced with something like Me("lblFileName" &
GridRowNo).

The scrollbar can be made with a few labels and a command button. Use
Windows Paint to create a couple of up and down arrow bitmaps. The
command button is vital, although it is set to transparent. It
intercepts all of the mouse events. Using these events a label can be
programmed to move as a slide bar. For this to work, the command
button must be topmost in the Z order. The slide label which is
visible operates just below the command button. The command button
must be as long as the label that will represent the scrollbar tray,
and be positioned exactly over it. Obviously the tray label will be
lowest in the z order, then the slide label, and finally the
transparent command button.

Labels cannot be used for editing. If you need to use this screen for
editing the records, then use an invisible textbox that is sized,
positioned over a label and made visible through code when a user
clicks on that label.

Use a variable called RecordInTopRow or something like that to hold
the number of the record currently residing in the top row of the
grid. This needs to be declared at form level. The scroll events
(mouse move events on the transparent command button) will modify this
number. A function needs to be written to take this number and
display a screenful of records. Concrete examples of all of this can
be found by searching the use-nets (google groups) with my name
(OldPro). If you need further assistance on any part of this, let me
know and I will go into more detail in a later message.- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Thanks for the detailed steps. I understand what to do and how is
should work. I will give it a try. Thanks for your help.

Dirk
 
O

OldPro

The following code shows how to create a custom scrollbar and
listbox.

First, create a new form and add:
1) a command button called cmdScrollBarTray; set to transparent.
2) a label called lblScrollBarTray; set to invisible with a
transparent border.
3) a label called lblScrollBarSlide, set to invisible, special
effect raised
4) a label called lblOutline, set background to transparent,
special effect sunken
5) 10 labels called lblName1 to lblName10, set border flat and
solid, set invisible=true
Position the first label at the top left corner of where the
grid should start.
6) 2 command buttons; cmdScrollBarPrevious and cmdScrollBarNext.
Add arrow graphics for a finished look.
Second, modify the code to use your own table and field (type Text).

Warning: Access TOP, LEFT, HEIGHT, and WIDTH properties do not
accurately describe the actual area that an Access control inhabits.
This example compensates by adding and subtracting numbers here and
there. If you swap controls, or change the border attributes of any
of the controls, the grid may not function properly.

Option Compare Database
Option Explicit
Private iScrollTop As Integer
Private iScroll_Y As Integer
Private iTopOfPage As Integer
Private iGridItemCount As Integer ' Total record count
' -----------
' Define grid
' -----------
Private Const ROWS_IN_GRID = 10
Private sName As String
Dim db As DAO.Database
Dim rsCompany As DAO.Recordset

Private Sub cmdScrollBarNext_Click()
If iGridItemCount > ROWS_IN_GRID Then
iTopOfPage = Min(iTopOfPage + 1, iGridItemCount - ROWS_IN_GRID +
1)
ScrollBarRefresh iTopOfPage
Grid_Refresh iTopOfPage
End If
End Sub

Private Sub cmdScrollBarPrevious_Click()
If iGridItemCount > ROWS_IN_GRID Then
iTopOfPage = Max(iTopOfPage - 1, 1)
ScrollBarRefresh iTopOfPage
Grid_Refresh iTopOfPage
End If
End Sub


Private Sub cmdScrollBarTray_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Dim x1 As Long
Dim y1 As Long
Dim dblSlideRatio As Double

'If the user clicks withing the slide area then...
If (Y >= (lblScrollBarSlide.Top - cmdScrollBarTray.Top)) And (Y <=
(lblScrollBarSlide.Top + lblScrollBarSlide.Height) -
cmdScrollBarTray.Top) Then
iScrollTop = lblScrollBarSlide.Top
iScroll_Y = Y
' If the user clicks below the slide then...
ElseIf Y > (lblScrollBarSlide.Top + lblScrollBarSlide.Height -
cmdScrollBarTray.Top) Then

iTopOfPage = Min(iTopOfPage + 1, iGridItemCount - 1)
dblSlideRatio = iTopOfPage / (iGridItemCount - 1)
lblScrollBarSlide.Top = dblSlideRatio * (cmdScrollBarTray.Height
- lblScrollBarSlide.Height) + cmdScrollBarTray.Top

' If the user clicks above the slide then...
ElseIf Y < (lblScrollBarSlide.Top - cmdScrollBarTray.Top) Then
iTopOfPage = Max(iTopOfPage - ROWS_IN_GRID, 1)
dblSlideRatio = (iTopOfPage - 1) / (iGridItemCount - 1)
lblScrollBarSlide.Top = dblSlideRatio * cmdScrollBarTray.Height
- lblScrollBarSlide.Height + cmdScrollBarTray.Top
End If
End Sub

Private Sub cmdScrollBarTray_MouseMove(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Dim dblSlideRatio As Double
Dim iNewTopOfPage As Integer
Dim iRecTally As Integer
Static l As Long

If iScroll_Y <> -10000 Then
lblScrollBarSlide.Top = _
Min(Max(iScrollTop + (Y - iScroll_Y), cmdScrollBarTray.Top),
(cmdScrollBarTray.Top + cmdScrollBarTray.Height) -
lblScrollBarSlide.Height)

iScrollTop = lblScrollBarSlide.Top
iScroll_Y = Y

dblSlideRatio = (lblScrollBarSlide.Top - cmdScrollBarTray.Top) /
(cmdScrollBarTray.Height - lblScrollBarSlide.Height)
If iGridItemCount > ROWS_IN_GRID Then
' ----------------------------------------------------
' -1 *(Int(-1*num)) always rounds a positive number up
' ----------------------------------------------------
iNewTopOfPage = -1 * (Int(-1 * (dblSlideRatio *
(iGridItemCount - ROWS_IN_GRID) + 1)))

If iNewTopOfPage <> iTopOfPage Then
Grid_Refresh iNewTopOfPage
End If
iTopOfPage = iNewTopOfPage
End If
End If
End Sub

Private Sub cmdScrollBarTray_MouseUp(Button As Integer, Shift As
Integer, X As Single, Y As Single)
iScroll_Y = -10000
End Sub
Private Sub SetupGrid(iTop As Integer, iLeft As Integer, iHeight As
Integer, iWidth As Integer, iScrollBarWidth As Integer)
Dim iRowTally As Integer
' Setup outline
lblOutline.Top = iTop - 15
lblOutline.Left = iLeft - 15
lblOutline.Height = iHeight + 30
lblOutline.Width = iWidth + iScrollBarWidth + 30
' Setup cells
For iRowTally = 1 To ROWS_IN_GRID
Me("lblName" & Format(iRowTally)).Left = iLeft
Next
iLeft = lblName1.Left + lblName1.Width + 15
SetupScrollBar iTop, iLeft, iHeight, iScrollBarWidth
End Sub
Private Sub SetupScrollBar(iTop As Integer, iLeft As Integer, iHeight
As Integer, iWidth As Integer)

' Setup the UP button
cmdScrollBarPrevious.Top = iTop
cmdScrollBarPrevious.Left = iLeft
cmdScrollBarPrevious.Height = iWidth
cmdScrollBarPrevious.Width = iWidth
' Setup the scroll tray
lblScrollBarTray.Top = cmdScrollBarPrevious.Top +
cmdScrollBarPrevious.Height + 15
lblScrollBarTray.Left = iLeft
lblScrollBarTray.Height = iHeight - (2 * iWidth) - 30
lblScrollBarTray.Width = iWidth
' Setup the scroll slide
lblScrollBarSlide.Top = lblScrollBarTray.Top
lblScrollBarSlide.Left = iLeft
lblScrollBarSlide.Height = 3 * iWidth
lblScrollBarSlide.Width = iWidth - 15
' Setup the scroll tray command button
cmdScrollBarTray.Top = lblScrollBarTray.Top
cmdScrollBarTray.Left = iLeft
cmdScrollBarTray.Height = iHeight - (2 * iWidth) - 30
cmdScrollBarTray.Width = iWidth
' Setup the DOWN button
cmdScrollBarNext.Top = iTop + iHeight - iWidth
cmdScrollBarNext.Left = iLeft
cmdScrollBarNext.Height = iWidth
cmdScrollBarNext.Width = iWidth
' Turn controls visible
cmdScrollBarPrevious.Visible = True
lblScrollBarTray.Visible = True
lblScrollBarSlide.Visible = True
cmdScrollBarTray.Visible = True
cmdScrollBarNext.Visible = True
End Sub

Private Sub Form_Load()
Dim iGridTop As Integer
Dim iGridLeft As Integer
Dim iGridHeight As Integer
Dim iGridWidth As Integer
Dim iScrollWidth As Integer
iScroll_Y = -10000
Set db = CurrentDb()
Set rsCompany = db.OpenRecordset("tblLocation", dbOpenTable)
' ------------------------------------
' Select the position and size of grid
' ------------------------------------
iGridItemCount = rsCompany.RecordCount
iGridTop = lblName1.Top
iGridLeft = lblName1.Left
iGridHeight = lblName1.Height * ROWS_IN_GRID
iGridWidth = lblName1.Width
iScrollWidth = 300

SetupGrid iGridTop, iGridLeft, iGridHeight, iGridWidth,
iScrollWidth
iTopOfPage = 1

Grid_Refresh iTopOfPage
End Sub

Private Sub Form_Unload(Cancel As Integer)
rsCompany.Close
Set rsCompany = Nothing
db.Close
Set db = Nothing
End Sub

Private Function Grid_Refresh(iStartRecord As Integer)
Dim iRow As Integer
Dim bDone As Boolean
Dim iRowTally As Integer
Dim cTotalPayment As Currency
Dim iRecordTally As Integer
On Error GoTo ErrorTrap
cTotalPayment = 0
bDone = False
iRowTally = 0
iRecordTally = 0
With rsCompany

.MoveFirst
If .EOF Then
bDone = True
End If
While Not bDone
iRecordTally = iRecordTally + 1
If iRecordTally >= iStartRecord Then
iRowTally = iRowTally + 1
If iRowTally <= ROWS_IN_GRID Then
Me("lblName" & Format(iRowTally)).Caption =
AddAmperstands(!LocName)
End If
End If
.MoveNext
If .EOF Then
bDone = True
End If
Wend
For iRow = iRowTally + 1 To ROWS_IN_GRID
Me("lblName" & Format(iRow)).Caption = ""
Next
End With
Exit Function
ErrorTrap:
MsgBox "Error:" & Err.Description
End Function

' ==============================================
' Add an extra amperstand after every amperstand
' so that it displays correctly in a label.
' ==============================================
Private Function AddAmperstands(sTarget As String) As String
Dim sNewFormat As String
Dim iTargetLength As Integer
Dim iLetterTally As Integer

sNewFormat = ""
iTargetLength = Len(sTarget)
For iLetterTally = 1 To iTargetLength
sNewFormat = sNewFormat + Mid(sTarget, iLetterTally, 1)
If Mid(sTarget, iLetterTally, 1) = "&" Then
sNewFormat = sNewFormat + "&"
End If
Next
AddAmperstands = sNewFormat
End Function
' ==============================================================
' ScrollBarRefresh(iTopOfPage As Integer)
' --------------------------------------------------------------
' Repositions the scrollbar when the UP or DOWN arrows are used.
' ==============================================================
Private Sub ScrollBarRefresh(iTopOfPage As Integer)
Dim lngWiggleRoom As Long
Dim lngNewOffset As Long
Dim dblSlideRatio As Double
Dim lngTotalRecords As Long
lngTotalRecords = rsCompany.RecordCount
dblSlideRatio = (iTopOfPage - 1) / (lngTotalRecords - ROWS_IN_GRID)
lngWiggleRoom = cmdScrollBarTray.Height - lblScrollBarSlide.Height
lngNewOffset = dblSlideRatio * lngWiggleRoom
lblScrollBarSlide.Top = lngNewOffset + cmdScrollBarTray.Top
End Sub
Private Function Min(vNumber1 As Variant, vNumber2 As Variant) As
Variant
Min = IIf(vNumber1 < vNumber2, vNumber1, vNumber2)
End Function
Private Function Max(vNumber1 As Variant, vNumber2 As Variant) As
Variant
Max = IIf(vNumber1 > vNumber2, vNumber1, vNumber2)
End Function
 
O

OldPro

The previous version didn't handle clicking in the tray area above or
below the slide correctly. To correct it, replace it with the
following sub:

Private Sub cmdScrollBarTray_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Dim x1 As Long
Dim y1 As Long
Dim dblSlideRatio As Double

'If the user clicks withing the slide area then...
If (Y >= (lblScrollBarSlide.Top - cmdScrollBarTray.Top)) And (Y <=
(lblScrollBarSlide.Top + lblScrollBarSlide.Height) -
cmdScrollBarTray.Top) Then
iScrollTop = lblScrollBarSlide.Top
iScroll_Y = Y
' If the user clicks below the slide then...
ElseIf Y > (lblScrollBarSlide.Top + lblScrollBarSlide.Height -
cmdScrollBarTray.Top) Then

iTopOfPage = Min(iTopOfPage + ROWS_IN_GRID, iGridItemCount -
ROWS_IN_GRID + 1)
ScrollBarRefresh iTopOfPage
Grid_Refresh iTopOfPage

' If the user clicks above the slide then...
ElseIf Y < (lblScrollBarSlide.Top - cmdScrollBarTray.Top) Then
iTopOfPage = Max(iTopOfPage - ROWS_IN_GRID, 1)
ScrollBarRefresh iTopOfPage
Grid_Refresh iTopOfPage

End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top