In subform of a MS Access form, how to hide/show the vertical scroll bars as needed? - ms-access

I have a subform in an MS Access form which is not hiding/showing the vertical scroll bars as needed. In the example picture, the vertical scroll bar is showing even though there aren't enough records to warrant vertical scrolling. How do I get the scroll bars to show only when they are needed? Do I need to add an if-then condition to the on_load event? or is there an easier option?
Example http://www.freeimagehosting.net/uploads/37834d1d76.jpg

You may find something on these lines suits:
If Me.Recordset.RecordCount > 10 Then
Me.ScrollBars = 2 ''Vertical only
Else
Me.Scrollbars = 0 ''Neither
End If

Related

MS-ACCESS Conditional Formatting while scrolling

I have a continuous subform (Data) within a single form (Main) where I use conditional formatting. The problem is, when I click the scroll bar to go down the list, the conditional formatting is removed until I un-click the scroll bar. Scrolling through the list with the mouse wheel works perfectly.
I suspect this is due to a refreshing or repainting of the formatting that is inherently triggered by a click?
I tried using Application.Echo False, and Me.Repaint = False, with no luck (although I am not even sure where I would need to put these).
Does anyone have any experience with this? Note, the data displayed via subform Data is static, meaning the user cannot update the fields within this particular subform (not sure if that simplifies anything).
On a continuous form, conditional formatting is only performed on records that are within view. As new records are scrolled into view, there is a brief delay while the conditional formatting is calculated. As records are scrolled out of view, their conditional formatting is discarded. You should find that scrolling with the mouse wheel does have a bit of a delay in the conditional formatting.
In some situations, one solution is to build the conditional formatting into the recordsource. For example, suppose negative values for Balance should be shown with a yellow background, and you would like to be able to scroll quickly through all the records looking for yellow ones.
I do this by adding another field to the recordsource:
IIf([Balance] < 0, String(30,ChrW(9608)), "") AS BalanceBG
and then binding this to a TextBox with text color of yellow and font of Courier.
The 9608 character is a solid block, and a string of them fit tightly together to make a solid bar.
With this TextBox positioned behind the TextBox for [Balance], the yellow background will show even as the scrollbar thumb is dragged up and down.

Is there a programatic way to deal with subform / scrollbar situations in MS Access?

SHORT DESCRIPTION: I need to see all the columns in a datasheet subform. Specifically - 12 columns of months. To do that, I need a horizontal scroll bar. To get to that scroll bar is a challenge. I am developing in MS Access 2007.
THOROUGH DESCRIPTION:
I have a subform 'frm_SP' which displays in datasheet view that is 22" wide which is limit in width for a form - it is nested in another subform called 'frm_stage'.
I finally discovered that no matter how wide I make the very top "Parent form - 'frm_Entry' I can't seem to make ALL of this 3rd nested subform 'frm_SP' visible. The horizontal bar at the bottom just seems to compensate by proportionately growing to keep the limitation intact - this is frustrating.
As you can see in this image below, I have to scroll down to see the horizontal scroll bar. Why is it so far down? Did I specify that somewhere? It keeps that distance no matter how many records exist in the datasheet. So if it only had 4 records, I'd still have to scroll all the way down to see the scroll bar.
Similarly, I have a set of records that go beyond the horizontal scroll bar and I have no way of making the window large enough to see those records. So I have had to tell the client to open the actual table if they need to edit those records.
I have hesitated to post anything like this because it requires images, but now that I have done the work, hopefully this can solve a lot of issues for other users. Maybe this is the reason that there aren't many answers on the web that I can find.
Any tips, suggestions for alternate methods are welcome.
I added "SendKeys" code for the arrow keys so that that the 12 boxes would function more like a spreadsheet.
But I don't understand why January is skipped and then it continues to skip every 2 boxes
Here is the code:
Private Sub txtDEC_NC_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 40 'down
SendKeys "{TAB}", False
Case 38 'up
SendKeys "+{TAB}", False
End Select
End Sub
If you haven't already, try increasing the size of your 2nd-level form (as well as the subform control on that 2nd-level, which houses the bottom level form).
It looks like your bottom level form (with a max width of 22") requires a horizontal scroll bar in order to display within your 2nd-level form. This causes the scroll bar to appear within your 2nd-level form (where you have to scroll-- within the top form-- down in order to see it).
Instead, you probably would prefer that scroll bar to appear on your top-level form, which I believe you will get if your 2nd-level form (and the subform control for your bottom-level form) are also set to a max-width of 22".
The bottom level form will then display within the middle form without the need for a middle-form scroll bar, and the one (and only) scroll bar will render on the top form, where it will always be easily accessible without the need to scroll down first.
I have some thoughts on what causes the extra vertical white space in your second form, but I wonder if the above might not solve your problem.
Just a thought. (And I realize that this is a very old question, so perhaps you no longer need any suggestions here--in that case, I'll just leave this comment for others who may have a similar issue in the future).

Access Vertical Scrollbar focus on top of the form

Any ideas on how to keep the scrollbar/focus on the top of a form?
I have continous form with many textboxes and listboxes that make the user scroll down the form no matter the resolution size of their screen. Ever since I implemented a Listbox with a rowsource query that will vary on the record, every time I change records the vertical scrollbar of the form will change focus to the bottom of the form.
I tried changing focus to controls on the top of the page or changing ways to change the rowsource of said listbox (using vba code like listbox.RowSource = theSQLQUERY or making the rowsource of the listbox with the sqlQuery). It used to work before I implemented that sourcecode, it had a sourcecode before and the problem never happened.
The rowsource query looks like this :
where active_flag = 0
My question is, How can I keep the vertical scrollbar/focus on the top of a form taking into account the listbox that changes rowsource?
The key is:
Ever since I implemented a Listbox with a rowsource query that will vary on the record, every time I change records the vertical scrollbar of the form will change focus to the bottom of the form.
Your code is iterating through every single record, from top to bottom. It goes to the bottom because that's where the code stops. That's fine, it's how Access works.
So, after that code, add the following:
Me.Recordset.MoveFirst
Or
DoCmd.GoToRecord acDataForm, Me.Name, acFirst

FormFooter Visible property - Proportion form height accordingly

When trying to toggle the FormFooter's visible property, how do you ensure that when the footer is switched to visible=Yes that it grows out the bottom of the form rather than growing in to the Detail section of the form?
I've tried setting CanGrow properties of all sections to yes. I've even tried to update the height property of the Details section to the additional proportion taken up by the height of the footer section when it is visible. Neither of these work and there doesn't seem to be an overall form height property that I can adjust via VBA.
I'm looking to hide a section of controls in a pop-up form that are only revealed when the user clicks a button. Was hoping to do this in the foot section and then simply use the command button to toggle the FormFooter's visible property, but can't seem to do this without it either encroaching on the Detail section or adding a scroll bar to the Detail section.
I think you want to avoid cannibalizing the form's Detail area when you make the FormFooter visible. The only way I know to do that is to increase the form's WindowHeight by the amount (FormFooter.Height) needed to accommodate the footer.
However, the WindowHeight property is read-only, so you can't change it directly. Instead, you can use the form's Move method to resize the form. Resizing the form indirectly changes the WindowHeight property value.
This VBA procedure did what I think you want when tested in Access 2007. And it did that for my pop-up form without causing any noticeable display flicker, which was a pleasant surprise.
Private Sub cmdToggleFooter_Click()
Dim lngWindowHeight As Long
If Me.FormFooter.Visible = True Then
' reduce WindowHeight by FormFooter.Height
lngWindowHeight = Me.WindowHeight - Me.FormFooter.Height
Else
' increase WindowHeight by FormFooter.Height
lngWindowHeight = Me.WindowHeight + Me.FormFooter.Height
End If
' adjust form's window size
Me.Move Left:=Me.WindowLeft, Height:=lngWindowHeight
' toggle FormFooter.Visible
Me.FormFooter.Visible = Not Me.FormFooter.Visible
End Sub
Have the footer visible at design time, so that it is visible (very briefly, at worst) when the form is being loaded. Then put a FormFooter.Visible=false in the Form Load.

How to display the left side of a continuous form with a scrollbar at opening

I have continuous forms made of a header section and a detail section. Controls in detail section are bound to a recordset, while the ones in the header are not bound.
At opening time, focus is made on the first (left) control of the detail section or, if the recordset is empty, first (left) control of the header section. In such a situation, and for forms that need an horizontal scrollbar, the scrollbar will be set to the right side of the form, and left-side info wil be hidden, confusing the user.
Any way to make sure that, in all case, my form will open with its left side visible?
Thanks
Usually to avoid focus discrepancies, I use a small transparent button that I just call btDeadFocus in the header -or the detail section- of my forms.
This invisible button doesn't actually do anything more than capturing the focus. I just make sure that this button is set it as the first control on the form using the tab order list.
The button also becomes useful in situations where the focus cannot be kept on a control. For instance a control that needs to be disabled. I just move it to the btDeadFocus instead.