delay in FormCurrent() event - Access 2007

jerryczarnowski

Registered User.
Local time
Today, 14:24
Joined
Jan 29, 2012
Messages
31
Hello,

I have a routine that sets the name property of an image control to a string variable representing the directory path, the value of a field, and a file extension. The code resides in the FormCurrent() event so when the user clicks on the next record, the image control updates. Works great in 2010 but in 2007, it always shows the previous record. Below is the code...Is there some additional code needed?

Private Sub Form_Current()
Dim PartPicName As String
PartPicName = "C:\part_pictures\" & Me.[Part Number].Value & ".jpg"
PartPicNameImage.Picture = PartPicName
End Sub

I do my testing at home on 2010 but work has 2007.
Any help is greatly appreciated.

Thanks, Jerry
 
The code below shows a different picture when user steps through records.

Private Sub Form_Current()
Dim PartPicName As String
PartPicName = "C:\part_pictures\" & Me.[Part Number].Value & ".jpg"
PartPicNameImage.Picture = PartPicName
End Sub

As I had mentioned in the previous post, I have problems in 2007 but not in 2010. Is there a more efficient way of showing picures in an image control that would work in either version of Access?
 
Hi

Your Office 2007 is updated with the package Sp3?

Use the breakpoint in the code to know if the event is running. Analyze the value of Me.[Part Number].Value

Open the VBA> Debug menu, click Compile. If you find any errors, fix.

You are using the application with the extension ACCDE? ACCDE is not compatible between versions
 
Hi Ari,

Thanks for the quick reply. I don't know if we are updated to SP3 at work but I will definitely try the debug. I will have to try this out in a week as me and my sons are going on a fishing trip. Will let you know how it goes as soon as I can. Is this the right approach for updating the image control while moving through records? Are there alternatives?

Thanks, Jerry
 
Hi Ari,

I was able to debug...threw in a few temporary stop commands before and after each sub and while single stepping through, found that the following code causes the Form_Current() event to be triggered twice.

DoCmd.OpenForm "Scheduling"
Forms![Scheduling].RecordSource = sqlRecordSource

added some logic to hide the image control on the first occurance of the Form_Current() event, then turned it back on. Thanks for pointing me in the right direction.

Jerry
 
it may be an issue with the screen refresh timing

try adding the line

doevents

after the picture assignment statement. it may help, and will do no harm. it just lets the processor complete any pending tasks, such as screen repaints. it may be that a2007 AND a2010 behave slightly differently.
 
Hi Dave,

Tried the doevents and it caused a flicker in 2010 but will try it in 2007 at work. As you had said, no harm done and it may be something I use down the road.

Thanks, Jerry
 

Users who are viewing this thread

Back
Top Bottom