Record Navigation Buttons

Ethereal

Warcraft III Player
Local time
Today, 14:34
Joined
Jan 17, 2006
Messages
99
Ok, I am trying to make some sort of thumbnail preview form. The image appears in the imgBox no problem, and it is grabbing it from the field. When I use a combo box to navigate the records it works flawlessly

HOWEVER, I would like my users to be able to press bckwds/fwds arrows so i made some arrows with the wizard and added some code. Heres how it looks

---------------------------------------
Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click

DoCmd.GoToRecord , , acNext
Me.Requery
If Me!SamPhoto = "" Or IsNull(Me!SamPhoto) = True Then
imgSamPhoto.Picture = ""
lblNoPhoto.Visible = True
Else
lblNoPhoto.Visible = False
imgSamPhoto.Picture = Me![SamPhoto]
End If
MsgBox Me!SamPhoto
Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click

End Sub

Private Sub cmdPrevious_Click()
On Error GoTo Err_cmdPrevious_Click


DoCmd.GoToRecord , , acPrevious
Me.Requery
If Me!SamPhoto = "" Or IsNull(Me!SamPhoto) = True Then
imgSamPhoto.Picture = ""
lblNoPhoto.Visible = True
Else
lblNoPhoto.Visible = False
imgSamPhoto.Picture = Me![SamPhoto]
End If

Exit_cmdPrevious_Click:
Exit Sub

Err_cmdPrevious_Click:
MsgBox Err.Description
Resume Exit_cmdPrevious_Click

End Sub

Private Sub Form_Load()
DoCmd.GoToRecord , , acFirst
End Sub

------------------------------------------

My problem is that it never goes to the second record when i press next, and when i press back it says at end of recordset ( which makes sense ) but why would the back button work, and the fwd button do nothing ? I am hoping it is a small syntax error. Please help!
 
You're requerying after each move, delete the requery statment. mere moves are sufficient.
 
Thanks! worked great
 
OK, Now I have this as my code:
---------------------------------
Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click
DoCmd.GoToRecord , , acNext
If Me.SamID = DMax("SamID", "tSample", "SamPhoto Is Not Null") Then
cmdPrevious.SetFocus
cmdNext.Enabled = False
End If
imgSamPhoto.Picture = Me![SamPhoto]
cmdPrevious.Enabled = True
Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox Err.Description
Resume Exit_cmdNext_Click
End Sub
Private Sub cmdPrevious_Click()
On Error GoTo Err_cmdPrevious_Click
DoCmd.GoToRecord , , acPrevious
If Me.SamID = FirstRec Then
cmdNext.SetFocus
cmdPrevious.Enabled = False
End If
cmdNext.Enabled = True
imgSamPhoto.Picture = Me![SamPhoto]
Exit_cmdPrevious_Click:
Exit Sub
Err_cmdPrevious_Click:
MsgBox Err.Description
Resume Exit_cmdPrevious_Click
End Sub
--------------------------------------
Now it works fine if the user isn't hasty, but due to loading pictures for every move, If the user clicks a button too fast it won't disable it fast enough, and they get to "end of recordset" msgBox popping up. Is there any way to "pause" the form while the picture loads ?
 
Insert a "DoEvents" (of course, without the quotation marks) after each "imgSamPhoto.Picture = Me![SamPhoto]".
 
I still seem to be getting the error with that. So what i've done is disabled all of the controls while the code executes. and then enable the specific ones at the end. Seems to be working except if i press enter really fast it "cancels previous action"
 
If the picture is a bmp, convert it to a jpg, which will be smaller and load faster.

Display the Hourglass to indicate code is running. Then turn it off when complete.

Maybe, temporarily disable the "Enter" key too, with a macro.
 

Users who are viewing this thread

Back
Top Bottom