Subform's on_current event runs multiple times

NeAlvey

New member
Local time
Yesterday, 23:16
Joined
Oct 21, 2005
Messages
9
I'm trying to clean up one HUGE and ugly form by using subforms within tabs. I have a main form with "BottleID" as the key field and linking field. The tab displays pictures based on the BottleID and it works like a dream. My problem is that the "on_current" event happens 4 times on each record. For instance, I go up a record and it sets Picture1.value 4 times and it's the same thing everytime.

I'm wondering if the problems is due to bad table design. Everything is located within one table and I'm really unable to change this. It's been like this from the get go and too much to change to break it apart. Anyway, the subform is pulling data from the same table. I thought maybe this was the cause.

I'd post the database if possible, however there are hardcoded directory's and will not work unless they are all set up. Not worth it IMO. Any ideas? I tried doing the BottleID = forms!frmMain!BottleID instead of the auto-link in Access but it gives me several errors and I don't believe it buys me anything. Thanks in advance!
 
I've noticed that it appears to be going through the on_current event 4 times. However, if you're on record 20, go up to 21, then back to 20, it only runs the on_current event 2 times for record 20.

Also, if I open the subform by itself (not within the main form) and go through the records, it runs fine. Only does the on_current event once.

The on_current code is:
ShipDir = CurrentDBDir()
If IsNull(Picture1.Value) Then
imgPicture1.Picture = ShipDir & "images\NoPicture.jpg"
Else
imgPicture1.Picture = ShipDir & "images\" & Picture1.Value
End If
If IsNull(Picture2.Value) Then
imgPicture2.Picture = ShipDir & "images\NoPicture.jpg"
Else
imgPicture2.Picture = ShipDir & "images\" & Picture2.Value
End If
If IsNull(Picture3.Value) Then
imgPicture3.Picture = ShipDir & "images\NoPicture.jpg"
Else
imgPicture3.Picture = ShipDir & "images\" & Picture3.Value
End If
If IsNull(Picture4.Value) Then
imgPicture4.Picture = ShipDir & "images\NoPicture.jpg"
Else
imgPicture4.Picture = ShipDir & "images\" & Picture4.Value
End If

Other subs on the form are:
cmdAddPictures_click
cmdAddPictures_exit
cmdRemovePictures_click
Form_Open (defines directory of db)
cmdSave_click

Any ideas? Completely dumfounded!
 
Last edited:
Thanks Pat for the reply...I've actually found another way around it now. I figure that since it isn't using multiple tables, I could just use frames within the tabs. If I broke the table apart into multiple tables then it worked better, but I can only imagine what that would do to the queries!
 

Users who are viewing this thread

Back
Top Bottom