What events fire on record change on split form spreadsheet?

melissa_may1

Registered User.
Local time
Today, 07:42
Joined
Nov 29, 2011
Messages
41
Hi All,

I'm using a split form to display client information. I have an icon for Female clients and Male clients, that I change in code to match the client. The code to change the icon is in the AfterUpdate event for the male/female checkbox

I have custom navigation buttons, and when I use those, the AfterUpdate event fires, and the icon changes.

However, when I change records using the built-in record nav buttons at the bottom of the form, the icon does not change.

Also, if I click on a row in the spreasheet part of the form, the icon does not change.

In order to fix this, I've tried to add another event, but I can't seem to find the one that will work.

On the Form I tried OnDataChange, AfterRender, OnQuery, OnCurrent, AfterUpdate, BeforeUpdate, OnDirty, none of which would work.

Then I tried to attach another event to one of the other controls that changes, such as the client ID. I tried: AfterUpdate, BeforeUpdate, OnDirty, OnChange, and again, none work.

The only way I could find was to set a timer on the form, and use the OnTimer event to update it every second. But that makes the form flicker each time, and is a waste of resources.

Any ideas on what event I can watch for whenever the built-in navigation buttons are clicked, or when a row in the spreadsheet is clicked?

Also, why is there no event when the information on the form controls change, regardless of what caused the change?

Thanks!
 
OnCurrent is the event. If nothing happens then show the code.
 
You explanation is a little murky to me, especially the part about AfterUpdate (BTW, what AfterUpdate?) firing when you change Records. But for code that needs to be executed when you change Records you need to use the Form_Current event.

So, if I understand you correctly, you'd need your code in the male/female AfterUpdate event and the Form_Current event.

Linq ;0)>
 
A form in datasheet doesn't display images in an Image Control. A continuous form will work but you will need to bind the Image Control to a source.
 
Hi missinglinq,

Thanks for your reply!

You explanation is a little murky to me, especially the part about AfterUpdate (BTW, what AfterUpdate?)...


Third sentence in post:
"The code to change the icon is in the AfterUpdate event for the male/female checkbox."

But for code that needs to be executed when you change Records you need to use the Form_Current event.

Eighth sentence in post:
"On the Form I tried ... OnCurrent, AfterUpdate... none of which would work."

I'm not sure how I could make this any less murky! ;)
 
Hi vbaInet!

A form in datasheet doesn't display images in an Image Control. A continuous form will work but you will need to bind the Image Control to a source.

Sorry for the confusion. The image is actually in the top part of the form, not in the spreadsheet part.
 
OK, I've narrowed this down a bit.

I put in some MsgBoxes to let me know when the picture should change.

In the Form_Current(), the code looks like this:

Private Sub Form_Current()

If (Me!chkMale = True) Then
MsgBox "Form OnCurrent - chkMale is True!"
imgIcon.Picture = "c:\icons\man2.jpg"
Else
MsgBox "Form OnCurrent - chkMale is False!"
imgIcon.Picture = "c:\icons\woman2.jpg"
End If

End Sub

The MsgBox comes up when it should, but the image does not change.

The same code is in Form_BeforeUpdate(), Form_Load(), chkMale_AfterUpdate() but without the MsgBoxes, and it works fine at the appropriate times.

Any idea why this is happening?

Thanks!
 
No idea - split forms have a huge number of subtle and not so subtle quirks.( Eg you cannot have a browser control in them.). The confusing bit here is, that your button (or checkbox, was it) does seem to cause a display/change of the icon.

Where is your image control? In the header or in the detail section of the form?
Grasping at straws: try adding imgIcon.Repaint and Me.repaint as the last two lines in the Form_Current.
 
No idea - split forms have a huge number of subtle and not so subtle quirks.( Eg you cannot have a browser control in them.).

Well, no reason why split forms shouldn't have quirks - just like most of Access!

The confusing bit here is, that your button (or checkbox, was it) does seem to cause a display/change of the icon.

Right! That's the part I don't understand. I'd expect this to work only one way, but not one way in one place, and a different way in another place!

Where is your image control? In the header or in the detail section of the form?

The image control is in the header of the form. I just tried moving it to the detail area, and it does the same thing.

Grasping at straws: try adding imgIcon.Repaint and Me.repaint as the last two lines in the Form_Current.

I tried both. imgIcon.Repaint results in Runtime error - Method or Data Member Not Found.

'Me.Repaint doesn't help.

Very strange!

But, I have it working, so that's good. No need to go on with this, I suppose.

I just like to find out the "why" of things like this, so I can avoid a similar problem in the future...

Thanks!
 
Well, I found a solution!

When I include the form name, it works.

Private Sub Form_Current()
If (Me!chkMale = True) Then
Forms![Client Form]!imgIcon.Picture = "c:\icons\man2.jpg"
'imgIcon.Picture = "c:\icons\man2.jpg"
Else
Forms![Client Form]!imgIcon.Picture = "c:\icons\woman2.jpg"
'imgIcon.Picture = "c:\icons\woman2.jpg"
End If
' Following line results in Runtime error - Method or Data Member Not Found
'imgIcon.Repaint
' The following line does not help
'Me.Repaint

End Sub

Very strange....
 
Just put this in the Control Source of the Image control:
Code:
=IIF([chkMale] = -1, "c:\icons\man2.jpg", "c:\icons\woman2.jpg")

You will need to tweak it to handle Null.
 

Users who are viewing this thread

Back
Top Bottom