Full Version: OnCurrent event for a continuous form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
HelloAgain
In one of my Access Databases I have a form that contains a continuous subform. The subform has enough space to display six records on the screen before the user would need a scroll bar to scroll down to see the rest of the records. Because of this, I want to set the form up so if there are six records or less in the subform, the scrollbars should disappear. More than six records, and I want the vertical scrollbar to appear. So in the OnCurrent event of the subform I placed the following code:

CODE
Select Case Me.RecordsetClone.RecordCount
        Case Is < 6
            Me.ScrollBars = 0
        Case Else
            Me.ScrollBars = 2
End Select


Which seems to work well, with one problem. I placed the code in the OnCurrent event of the subform so that as I delete and add records in the subform, it constantly recalculates whether or not it needs the scrollbars. The problem I am running into is if the I delete all of the records, or if I open the main form to a record that contains no records in the subform, the OnCurrent event never fires (presumably because because without any records in the subform, there can't be a current record). Does anyone know a way around this?
Paul_Churchill
Can you not run this code attached to the on current event of the PARENT form since you will always have a record in the main form but cannot guarantee one in the related subform - I'm not 100% sure that access will allow this but if it does then it should work.

regards
Paul

Edited by: Paul_Churchill on Tue Nov 6 9:56:42 EST 2007.
HelloAgain
Paul,

Thanks or your help. Moving the even to the parent form worked.

Thanks again.
Paul_Churchill
Great, I'm glad to know that Access did allow that

regards
Paul
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.