josephbupe
Registered User.
- Local time
- Today, 15:31
- Joined
- Jan 31, 2008
- Messages
- 247
Hi,
I am trying to modify a sample by Roggers here for my project to browse multiple images in MS Access form.
But, I would like to know how I can add an on-click event for the image control to open a details form.
The code behind the form is as follows:
My dilema is that I cannot use the usual link criteria here because the image controls in the form are numbers as Im_01 through Im_18, after that the user can use the navigation buttons to load a new set of images beyond the 18th image in the same controls. I hope you will understand from the linked sample itself.
I will appreciate your help.
Joseph
I am trying to modify a sample by Roggers here for my project to browse multiple images in MS Access form.
But, I would like to know how I can add an on-click event for the image control to open a details form.
The code behind the form is as follows:
Code:
Private Sub P_FillControls()
On Error GoTo ErrTrap
Dim Cnt As Long
Cnt = 1
Do Until (Cnt > BlockSize Or rst.EOF)
P_SetValues Cnt
Cnt = Cnt + 1
rst.MoveNext
Loop
If Cnt <= BlockSize Then
For Cnt = Cnt To BlockSize
P_SetNulls Cnt
Next
End If
ExitPoint:
On Error GoTo 0
Exit Sub
ErrTrap:
MsgBox Err.Number & " - " & Err.Description
Resume ExitPoint
End Sub
Private Sub P_SetValues(Cnt As Long)
On Error GoTo ErrTrap
If RecCount > 0 Then
Me("Rn_" & Format(Cnt, "00")).Caption = (rst.AbsolutePosition + 1)
Else
Me("Rn_" & Format(Cnt, "00")).Caption = ""
End If
Me("Lb_" & Format(Cnt, "00")).Caption = Nz(rst.Fields("ImageName"), "")
Me("Im_" & Format(Cnt, "00")).Picture = Nz(rst.Fields("ImageFile"), "")
Me("ID_" & Format(Cnt, "00")) = rst.Fields("ImageFile")
[COLOR=DarkGreen] ' Note - For no caption, dot is used in lieu of
' zero length string, so as to prevent the
' label from disappearing[/COLOR]
ExitPoint:
On Error GoTo 0
Exit Sub
ErrTrap:
MsgBox Err.Number & " - " & Err.Description
Resume ExitPoint
End Sub
Private Sub P_SetNulls(Cnt As Long)
On Error GoTo ErrTrap
Me("Rn_" & Format(Cnt, "00")).Caption = "."
Me("Lb_" & Format(Cnt, "00")).Caption = "."
Me("Im_" & Format(Cnt, "00")).Picture = "."
Me("ID_" & Format(Cnt, "00")) = Null
[COLOR=DarkGreen] ' Note - For no caption, dot is used in lieu of
' zero length string, so as to prevent the
' label from disappearing[/COLOR]
ExitPoint:
On Error GoTo 0
Exit Sub
ErrTrap:
MsgBox Err.Number & " - " & Err.Description
Resume ExitPoint
End Sub
Public Sub P_Initialize()
On Error Resume Next
RecCount = 0 [COLOR=DarkGreen] ' Default[/COLOR]
Me.LbNoImage.Visible = False
[COLOR=DarkGreen] ' Remove any existing instance of the recordset[/COLOR]
If Not rst Is Nothing Then
rst.Close
Set rst = Nothing
End If
[COLOR=DarkGreen] ' This recordset will finally get closed in form's
' close event.[/COLOR]
Set rst = CurrentDb.OpenRecordset("Q_ImageNormalSort")
[COLOR=DarkGreen] ' Set rst = CurrentDb.OpenRecordset("Q_Dynamic_Query")[/COLOR]
If rst.EOF And rst.BOF Then
[COLOR=DarkGreen] ' There are no records[/COLOR]
P_FillControls
Me.LbNoImage.Visible = True
P_SetStatusNavBtns
Me.CmdAdd.SetFocus
Exit Sub
End If
rst.MoveLast
RecCount = rst.RecordCount
LastID = rst.Fields("ImageFile")
rst.MoveFirst
FirstID = rst.Fields("ImageFile")
[COLOR=DarkGreen] ' First Load (signified by step size argument = 0)[/COLOR]
P_Next 0
Me.LbRecMsg.Caption = "Of " & RecCount
On Error GoTo 0
End Sub
My dilema is that I cannot use the usual link criteria here because the image controls in the form are numbers as Im_01 through Im_18, after that the user can use the navigation buttons to load a new set of images beyond the 18th image in the same controls. I hope you will understand from the linked sample itself.
I will appreciate your help.
Joseph