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
Related
In SSRS 2016, I have one report for multiple customers. Each customer have individual letterheads which are stitched behind the report after creation.
Now I want to change the position a textbox or tablix during runtime based on a x/y position value, which is stored in the application config for each customer.
How to achieve this? Entering an expression in the location property field doesn't work.
Without dynamic positioning I need to create a report for each customer which is a very bad workaround when you have dozens of them.
To position things vertically, dynamically, or at least give the impression it's doing this then you could try the following.
Be aware this is off the top of my head and untested.
Let's say the smallest logo on the letter head is 3cm and the largest is 6cm.
Position a textbox (let's refer to this as padTextBox) starting at 3cm from the top of the report. Set the height to something small (0.2cm or something).
Next add your textbox or tablix immediately under padTextBox.
Now we need to dynamically set the height of padTextBox.
We can do this by adding a dynamic number of blank lines to it at runtime.
It sounds like you have enough info already to determine the Y position. You need to convert this to a number of blank lines which in turn will depend on the font size set in padTextBox so for example, Y position 5cm might need 3 blank rows in padTextBox so the the bottom of the text box sits at 5cm.
To add the blank lines, I think you'll have to add a bit of custom code as I don't think there is a built in function that can repeat strings.
The following should do it
Public Function GetBlankRows(n as integer) as String
dim s as string
s = ""
dim i as integer
for i = 1 to n
s = s & vbcrlf
next i
return s
End Function
Finally, we need to set the expression for padTextBox to something like
=Code.GetBlankRows(Fields!YLines.Value)
or
=Code.GetBlankRows(Parameters!YLines.Value)
you get the idea...
Hope this helps ...
Unless it's not possible to set the position dynamically during runtime, what about setting it on build/deploy time?
The report files are XML. So having one master file for all customers under source control. When deployment is needed, a script (i.e. PowerShell) can open the file, reads the position for a specific customer from a config file or database and sets the relevant position values in the xml temporarily.
Then it builds and deploys the report for this customer and reverts the changes.
I have this really frustrating problem that may or may not be fixable due to an access technicality, but I'm going to ask anyway.
On a report, I have multiple subreports that display a list of documents; and the information within those subreports are outlined by a grid, so that it looks like the documents are in a table.
My problem is, if I have the border of these objects too close, then sometimes the gridline/border outline is thicker in some areas and not in others. Why is this? It's making the report look really inconsistent and unpresentable.
The only way to combat this, is to leave a space between the object and the border section of the form. But then this means the documents are split and look like they are in their own tables, rather than one big table if this makes sense?
I can't seem to find any solutions to this at all. I'd be very grateful if you know how to fix this or can provide an alternative solution!
Please see the attached images:
UPDATE: I'd just like to add, that when I view the report in 'Report View'; it is presented correctly. This inconsistency only appears when I view it in 'Print view' or if I export it.
Unfortunately, I was unable to find a simple answer as to why access creates these inconsistencies. However, I did find a workaround which solves the issue.
Used this as a reference: https://msdn.microsoft.com/en-us/library/office/aa221362(v=office.11).aspx
Add a horizontal line underneath the objects on the report. This will separate the document rows
To get the vertical lines, I had to insert them via VBA code. This is because I was unable to get vertical lines to expand when the objects grow
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim ctrl As Control
Dim intLineMargin As Integer
' This is the spacing between the right edge of the
' control and the Vertical Seperation Line
intLineMargin = 0
Loop through each control in the detail section of the subreport by selecting their Tags. The first object (Document) has an extra step, because you need vertical lines on both the left and right side.
First if statement creates the line on the left and right side for all controls with the tag 'DocumentName' (In this case, only the first object)
For Each ctrl In Me.Section(acDetail).Controls
With ctrl
If ctrl.Tag = "DocumentName" Then
Me.Line (0, 0)-(0, 0 + .Height + 150)
Me.Line ((.Left + .Width), 0)-(.Left + .Width + intLineMargin, .Height + 150)
End If
The rest of the objects have the tag 'DocumentDetails', and only need vertical lines on the RIGHT side of them. The if statement creates these vertical lines:
If ctrl.Tag = "DocumentDetails" Then
Me.Line ((.Left + .Width), 0)-(.Left + .Width + intLineMargin, .Height + 150)
End If
End With
Next
Set ctrl = Nothing
End Sub
Result:
All lines are now consistent
I wonder what would happen if you make the subreports be in datasheet view?
Otherwise I'd normally play around with line thicknesses, and make sure the control, section and subform heights were set exactly, and use the align tool to push your subreports together.
Or, as a last resort, I'd scrap the whole thing and load the pieces into a table and then make a subreport based off that. But I don't know what your stipulations are.
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)
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).
I have a set of two nested navigation subforms in an ms access 2010 database. The problem is that, when different users on different machines view the database through different screen resolutions and text size settings, the forms can have silly wastes of screen real estate, such as in the following image:
How do I set the width and height of each navigation subform so that each of the two navigation subforms has a small inset (30 pixels?) at the right and bottom, assuming that the left and top are fixed?
Here is the code that I worked up so far, but it pushes things too far to the right and to the bottom, without leaving the insets that I need at the right and bottom:
Main form (this is the outermost form):
Private Sub Form_Resize()
On Error Resume Next
Me.NavigationSubform.Width = Me.WindowWidth - (Me.NavigationSubform.Left + 10)
Me.NavigationSubform.Height = Me.WindowHeight - (Me.NavigationSubform.Top + 10)
End Sub
FindClientsNavigation form (this is the second level form):
Private Sub Form_Resize()
On Error Resume Next
Me.NavigationSubform.Width = Me.WindowWidth - (Me.NavigationSubform.Left + 10)
Me.NavigationSubform.Height = Me.WindowHeight - (Me.NavigationSubform.Top + 10)
End Sub
I uploaded a simplified version of the database with enough to recreate the problem at this file sharing site.
If you want to recreate the problem on your pc after downloading the database, you can set the windows text size property using the following dialog in the control panel:
Instead of messing about with code, set the HorizontalAnchor and VerticalAnchor properties of the subform controls appropriately at designtime, i.e. to Both. The default is for the horizontal anchor to be left only and the vertical anchor to be top only; setting to left-and-right and top-and-bottom will mean the control stretches accordingly when its parent resizes.
There is simple navigation available in ribbon. See the picture above.