Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically showing or hiding scroll bars in subforms

Status
Not open for further replies.

jaaret

Instructor
Jun 19, 2002
171
I've been attempting to show or hide the vertical scroll bar in a registration subform, depending on how many records are currently displayed.

If Form_sfrmRegistrations.txtRegistrations > 34 Then
Form_sfrmRegistrations.ScrollBars = 2
Else
Form_sfrmRegistrations.ScrollBars = 0
End If

The txtRegistrations field =count(EmpID) and displays the correct number of registrants.

Why is this not working?
 
How are ya jaaret . . .

Your code appears to be viable . . . its just a matter of where you calling it from . . . AKA . . . [blue]Form Referencing![/blue]

Calvin.gif
See Ya! . . . . . .
 
The code is called on a different subform that lists Events. The EventID is pulled from this subform to the main form and that field is the is the Master field for the sfrmRegistrations subform.

Here is the first part of the code in the sfrmEvents subform:

Private Sub txtEvent_Click()
On Error GoTo Err_txtEvent_Click

'Add the scroll bar to the registrant list if there are more than 34 registrants
'Otherwise, hide it


If Form_sfrmRegistrations.txtRegistrations > 34 Then
Form_sfrmRegistrations.ScrollBars = 2
Else
Form_sfrmRegistrations.ScrollBars = 0
End If

One other curious note, if I manually set the scroll bar property to Vertical Only in the sfrmRegistrations subform, it displays whent the form is first opened and it will disappear if I click on an event that has less than 35 registrants. However, it does not reappear when I click on event with > 34 registrants.

Curiouser and curiouser...
 
I have used the code below successfully in an application, I notice that my code references the form property to set the scrollbar value:
Code:
If Me.FrmMaintInvItems.Form.RecordsetClone.RecordCount = 0 Then
    Me.PageItem.Visible = False
ElseIf Me.FrmMaintInvItems.Form.RecordsetClone.RecordCount < 8 Then
    Me.PageItem.Visible = True
    Me.FrmMaintInvItems.Form.ScrollBars = 0
Else
    Me.PageItem.Visible = True
    Me.FrmMaintInvItems.Form.ScrollBars = 2
End If

You never know adding .Form.ScrollBars may help.
I used the record count property to determine how many records are returned in the subform.

Mark...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top