Detect scrollbar on subform (urgent)

  • Thread starter deBassMan via AccessMonster.com
  • Start date
D

deBassMan via AccessMonster.com

Hi all

A2K, Win XP Pro

I have an urgent need to be able to detect whether a subform is currently
displaying a vertical scrollbar.

I think a call to the API is required but I cannot get it to work.

any ideas would be gratefully received.

scott
 
F

freakazeud

Hi,
you don't need an API for that.
You can easily determine the scrollbar situation with the forms scrollbars
property.
An example of evaluating the state from the main form would be:

If Me.YourSubForm.Form.ScrollBars = 2 Then
'has vertical scrollbars
Else
'does not have vertical scrollbars
End If

HTH
Good luck
 
D

deBassMan via AccessMonster.com

Hi

thanks for your reply

the scrollbars property merely returns the scrollbars setting

I need to know if Access has switched on the vertical scrollbar (because
there are more records being displayed than can fit into the form)

the scrollbars property won't do this.

cheers


Hi,
you don't need an API for that.
You can easily determine the scrollbar situation with the forms scrollbars
property.
An example of evaluating the state from the main form would be:

If Me.YourSubForm.Form.ScrollBars = 2 Then
'has vertical scrollbars
Else
'does not have vertical scrollbars
End If

HTH
Good luck
[quoted text clipped - 8 lines]
 
D

Dirk Goldgar

deBassMan via AccessMonster.com said:
Hi

thanks for your reply

the scrollbars property merely returns the scrollbars setting

I need to know if Access has switched on the vertical scrollbar
(because there are more records being displayed than can fit into the
form)

the scrollbars property won't do this.

Maybe Stephen Lebans has some suitable code in his SetGetScrollbars
project at

http://www.lebans.com/SelectRow.htm
 
M

Marshall Barton

deBassMan said:
A2K, Win XP Pro

I have an urgent need to be able to detect whether a subform is currently
displaying a vertical scrollbar.

I think a call to the API is required but I cannot get it to work.

any ideas would be gratefully received.


I think it's probably easier to check the form properties to
than use an API.

You know how tall the form's detail area is and you know the
height of the detail section, so you can easily calculate
the number of details that can fit without using a scroll
bar. Then just check to see if the number of records in the
form is greater or less that the number that will fit.

Dim intNumRecs As Integer
intDisplayRecs = (Me.InsideHeight - Me.Section(1).Height _
- Me.Section(2).Height) / Me.Section(0).Height
With Me.RecordsetClone
.MoveLast
If .RecordCount > intDisplayRecs Then
' scroll bar is needed
Else
' scroll bar is not needed
End If
End With

If your form does not have the header/footer sections,
leave the Section 1 and 2 parts out of the expression.
 
D

deBassMan via AccessMonster.com

Hi

thanks for your reply but ....

as the users can drag the subform's rowheight taller or shorter - there's no
reliable way I can simply count the records.

I thought about somwhow disabling the user-adjustable rowheight in the
datasheet - but I cannot seem to find a way.

Stephen Lebans code does seem to work for me either.

there must be a way of determining if the datasheet is currently displaying a
vertical scrollbar

there is an answer out there ....


Marshall said:
A2K, Win XP Pro
[quoted text clipped - 4 lines]
any ideas would be gratefully received.

I think it's probably easier to check the form properties to
than use an API.

You know how tall the form's detail area is and you know the
height of the detail section, so you can easily calculate
the number of details that can fit without using a scroll
bar. Then just check to see if the number of records in the
form is greater or less that the number that will fit.

Dim intNumRecs As Integer
intDisplayRecs = (Me.InsideHeight - Me.Section(1).Height _
- Me.Section(2).Height) / Me.Section(0).Height
With Me.RecordsetClone
.MoveLast
If .RecordCount > intDisplayRecs Then
' scroll bar is needed
Else
' scroll bar is not needed
End If
End With

If your form does not have the header/footer sections,
leave the Section 1 and 2 parts out of the expression.
 
M

Marshall Barton

Then use the RowHeight property instead of the
Section(0).Height

intDisplayRecs = Me.InsideHeight / Me.RowHeight
--
Marsh
MVP [MS Access]

thanks for your reply but ....

as the users can drag the subform's rowheight taller or shorter - there's no
reliable way I can simply count the records.

I thought about somwhow disabling the user-adjustable rowheight in the
datasheet - but I cannot seem to find a way.

Stephen Lebans code does seem to work for me either.

there must be a way of determining if the datasheet is currently displaying a
vertical scrollbar

there is an answer out there ....


Marshall said:
A2K, Win XP Pro
[quoted text clipped - 4 lines]
any ideas would be gratefully received.

I think it's probably easier to check the form properties to
than use an API.

You know how tall the form's detail area is and you know the
height of the detail section, so you can easily calculate
the number of details that can fit without using a scroll
bar. Then just check to see if the number of records in the
form is greater or less that the number that will fit.

Dim intNumRecs As Integer
intDisplayRecs = (Me.InsideHeight - Me.Section(1).Height _
- Me.Section(2).Height) / Me.Section(0).Height
With Me.RecordsetClone
.MoveLast
If .RecordCount > intDisplayRecs Then
' scroll bar is needed
Else
' scroll bar is not needed
End If
End With

If your form does not have the header/footer sections,
leave the Section 1 and 2 parts out of the expression.
 
S

Stephen Lebans

Yes you can use the GDI to check the Form/Window's properties to see if the
Scrollbar is currently Visible or not but you might want to first retry
Marshall's suggestion.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


deBassMan via AccessMonster.com said:
Hi

thanks for your reply but ....

as the users can drag the subform's rowheight taller or shorter - there's
no
reliable way I can simply count the records.

I thought about somwhow disabling the user-adjustable rowheight in the
datasheet - but I cannot seem to find a way.

Stephen Lebans code does seem to work for me either.

there must be a way of determining if the datasheet is currently
displaying a
vertical scrollbar

there is an answer out there ....


Marshall said:
A2K, Win XP Pro
[quoted text clipped - 4 lines]
any ideas would be gratefully received.

I think it's probably easier to check the form properties to
than use an API.

You know how tall the form's detail area is and you know the
height of the detail section, so you can easily calculate
the number of details that can fit without using a scroll
bar. Then just check to see if the number of records in the
form is greater or less that the number that will fit.

Dim intNumRecs As Integer
intDisplayRecs = (Me.InsideHeight - Me.Section(1).Height _
- Me.Section(2).Height) / Me.Section(0).Height
With Me.RecordsetClone
.MoveLast
If .RecordCount > intDisplayRecs Then
' scroll bar is needed
Else
' scroll bar is not needed
End If
End With

If your form does not have the header/footer sections,
leave the Section 1 and 2 parts out of the expression.
 
D

deBassMan via AccessMonster.com

Hi guys

Marshall - I've used code similar to your suggestion and it works great -
thanks!

One problem is that there appears to be no rowheight resize event therefore
if the user resizes the rowheight of the subform so that the vertical
scrollbar either appears or disappears no recalculation takes place and the
wrong message is being displayed.

hmm GDI anyone?


Stephen said:
Yes you can use the GDI to check the Form/Window's properties to see if the
Scrollbar is currently Visible or not but you might want to first retry
Marshall's suggestion.
[quoted text clipped - 44 lines]
 
M

Marshall Barton

Without an event, how would you do it using an API? Seems
like the same problem regardless of how you calculate if all
the records are displayed.

Didn't you say earlier that you could make the row height
unchangable? The only way I've seen to do those things is
to use a Timer event and I avoid those like the plague.

Personally, I would use a continuous subform and make all
these side questions moot.
--
Marsh
MVP [MS Access]

Marshall - I've used code similar to your suggestion and it works great -
thanks!

One problem is that there appears to be no rowheight resize event therefore
if the user resizes the rowheight of the subform so that the vertical
scrollbar either appears or disappears no recalculation takes place and the
wrong message is being displayed.


Stephen said:
Yes you can use the GDI to check the Form/Window's properties to see if the
Scrollbar is currently Visible or not but you might want to first retry
Marshall's suggestion.
[quoted text clipped - 44 lines]
If your form does not have the header/footer sections,
leave the Section 1 and 2 parts out of the expression.
 
S

Stephen Lebans

Use the MouseUp event of the Form in Datasheet view.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


deBassMan via AccessMonster.com said:
Hi guys

Marshall - I've used code similar to your suggestion and it works great -
thanks!

One problem is that there appears to be no rowheight resize event
therefore
if the user resizes the rowheight of the subform so that the vertical
scrollbar either appears or disappears no recalculation takes place and
the
wrong message is being displayed.

hmm GDI anyone?


Stephen said:
Yes you can use the GDI to check the Form/Window's properties to see if
the
Scrollbar is currently Visible or not but you might want to first retry
Marshall's suggestion.
[quoted text clipped - 44 lines]
If your form does not have the header/footer sections,
leave the Section 1 and 2 parts out of the expression.
 
D

deBassMan via AccessMonster.com

mouseup event - excellent!

I didn't think of it either ... (never really used it before)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top