I have 2 forms; a parent form (frmResults) and a sub form located within the parent form (frmResultsSub). The sub displays the search results from a query, and will have horizontal and vertical scrollbars depending on the number of fields and records returned.
To give the user a better viewing experience of the results subform, I have been playing about with tyring to implement a method to automatically resize the subform (increasing the number of fields and records displayed) as the user drags in/out the parent form, and allowing them access to the sub's scrollbars at all times.
On the parent's Resize event I have the following...
Me.Section(0).Height = Me.InsideHeight
Me.frmResultsSub.Width = Me.WindowWidth - 700
If Me.WindowHeight > 2650 Then
Me.frmResultsSub.Height = Me.WindowHeight - 1850
End If
I have the parent form's scrollbars switched off - the only scrollbars present are those of the subform, and I have additional space at the parent top for extra info and a couple of cmd buttons.
To an extent, this works well...through trial and error (with 2 of the 3 numeric values above) there is a small border around the subform.
Problem:
I've had to place a minimal subform height of 2650 since Access will error out otherwise.
However, if the parent form is dragged too large Access still errors with a "Run-time error '2100' the control or subform is too large for this location"
Instead of adding more minimum and maximum subform values (if that would work), is there a better way to implement a subform resize, preferably also allowing for the parent form's min/max buttons to work. I have a few additional forms that would benefit with similar resizing.
Thanks for any help.
[Access 2003 compliance required]
Edit: I've added Me.Section(0).Height = Me.InsideHeight to try to adjust for the form's Detail section, but Access still throws the same error (I don't see a .Width equivalent for the Detail section)
Edit2: this problem seems identical to that seen at http://www.pcreview.co.uk/threads/maximum-width-if-a-subform-in-access-2k.2601154/ unfortunately, no answer was provided.
I've changed to using Me.InsideWidth / InsideHeight but still have Access error out when the subform tries to get wider that around 31560. Interestingly, Me.Width will only grow to about 31560 before it changes to a negative value...Me.InsideWidth continues to grow as a positive number as the window stretches wider. By only having a .Width property for the subform I wonder if this is the issue (the subform will change to a negative value at the same point, throwing the resize off)
Related
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.
First, my English is not very good.
Do you know if there is a way to make grow vertically and specific record of a continuous form while keeping the rest of records from growing? For example on reports if I set a textBox "letGrow" property to true, if the text inside that control occupies various lines the control grows, but just on that specific record. I would like similar behavior on forms "normalView".
Thankyou
That is not an option. CanGrow is for reports only.
You can adjust height on the fly, but that will touch all records displayed.
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).
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
How do you set heights and widths of subforms to be percent of available screen real estate in ms access 2010? In particular, I have a nested navigation subform labeled "Tab A" in the database that I uploaded to this file sharing url: http://jmp.sh/v/HGctZ4Ru74vDAjzN43Wq
In the database at the file sharing link, different users with different screen resolution settings have the navigation subform with Tab A showing up in all different sizes, including some where the subform is a ridiculously small percentage of the available screen real estate. The height of the detail section of the navigation subform is set to 5.5542 inches. Is there some way to set it so that the height is 90% of the space available below the top of the subform? I would also like for the width of the subform labeled "Tab 1" to be 90% of what is to the right of the left edge. In java, this is easy with offsets and calculated widths. I just cant seem to find instructions for how to do relative dimensions in access 2010.
Google searches on the topic don't seem to produce any solutions, and I want to avoid screwing up all the other users' screens by just adding an inch or two to the height setting.
In Access forms, all percentages or relative sizes are going to have to be calculated by you. I admit that sizing of forms and elements in Access is a little rigid and clumsy, but that's true of many desktop application GUI environments. I think .NET WPF has tried to fix this problem, but that has nothing to do with MS Access.
I usually end up using something like this. This code belongs on the main form. That's where I always do my resizing.
Private Sub Form_Resize()
On Error Resume Next
Me.subform1.Width = Me.WindowWidth - 390
'or if you want to account for the form's left property
'Me.subform1.Width = Me.WindowWidth - (Me.subform1.Left + 100)
End Sub
Edit1:
In answer to your comment, 390 and 100 are twips. While design-time in Access does using inches, runtime properties must be set using twips.
I messed with this for a bit and couldn't get anything I considered to be perfectly accurate. I'm posting the code below that makes the most logical sense to me, but then I don't know the ins and outs of how forms sizes are calculated in MS Access. It seems I'm probably missing something because the code below does not product accurate results. I found by increasing my Margins and decreasing the percentage/decimal for subform's height calculation I was able to get something that appeared relatively close but was unsatisfactory if you demand precise and exact numbers.
Private Sub Form_Resize()
On Error Resume Next
Const RMARGIN = 0
Const BMARGIN = 0
Me.subform1.Left = Round(Me.WindowWidth * 0.1) - RMARGIN
Me.subform1.Top = Round(Me.WindowHeight * 0.1) - BMARGIN
Me.subform1.Width = Round(Me.WindowWidth * 0.9) - (Me.subform1.Left + RMARGIN)
Me.subform1.Height = Round(Me.WindowHeight * 0.9) - (Me.subform1.Top + BMARGIN)
End Sub