473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Resizing Forms

Denburt
1,356 Expert 1GB
Wow Melissa you sound busy lol.

Can you explain about how to cascade updates and deletes? That sounds like good practice regardless of how the forms/subforms are displayed!
In the main Database window click on tools - relationships from there add your tables create the relationship and set it to referential integrity then set cascade update and deletes.That should take care of any problems with corelating the records. If you want you can disable each control that is on the main form but that is about the only other thing you might consider. You will need some way to exit the subform and enable all the controls also so think about that before you attempt the following:

Dim ctl As Control
For Each ctl In frm.Controls
If not ctl.ControlType = 122 Then
ctl.Enabled = false
end if
Next

For resizing subforms I use the following and it works pretty good...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Resize()
  2.   On Error GoTo ResizeError
  3. ResizeIt Me, Me!Hedging_subform, 300, 2800
  4. Exit_Sub:
  5. Exit Sub
  6. ResizeError:
  7.         MsgBox Err.Number & "   " & Err.Description
  8. End Sub
  9.  
  10. Sub ResizeIt(myFrm As Form, mySubFrm As Control, X As Integer, Y As Integer)
  11. On Error GoTo ResizeError
  12.  
  13.         'Turn off screen redraw
  14.         Application.Echo False
  15.         If mySubFrm.Top + mySubFrm.Height + 100 <= ((myFrm.InsideHeight - mySubFrm.Top) - Y) Then  'myFrm.InsideHeight Then
  16.             If Y > 0 Then
  17.                 mySubFrm.Height = ((myFrm.InsideHeight - mySubFrm.Top) - Y)
  18.             End If
  19.             myFrm.Section("DETail").Height = mySubFrm.Height
  20.             If X > 0 Then
  21.                 mySubFrm.Width = myFrm.InsideWidth - X
  22.             End If
  23.         Else
  24.             If Y > 0 Then
  25.                 If ((myFrm.InsideHeight - mySubFrm.Top) - Y) > 0 Then
  26.                     mySubFrm.Height = ((myFrm.InsideHeight - mySubFrm.Top) - Y)
  27.                 End If
  28.             End If
  29.             If X > 0 Then
  30.                 mySubFrm.Width = myFrm.InsideWidth - X
  31.             End If
  32.         End If
  33.  
  34.         'Turn screen redraw back on
  35.         Application.Echo True
  36.  
  37.     Exit Sub
  38. Exit_Sub:
  39. Exit Sub
  40.  
  41. ResizeError:
  42.         ' NB: Turn screen redraw back on if an error occurs!
  43.         Application.Echo True
  44.         MsgBox Err.Number & "   " & Err.Description
  45. End Sub
  46.  
Mar 20 '07 #1
13 4523
AccessIdiot
493 256MB
Thanks for the reply Denburt!

Actually I did figure out that I had the cascading already set when I created my table relationships diagram. :-)

I'm an Access noob and not very good with VB. Any chance you could explain your code a bit? Particularly the things I need to change for my own code? :-D

I imagine this line for example:
Expand|Select|Wrap|Line Numbers
  1. ResizeIt Me, Me!Hedging_subform, 300, 2800
I would change the name of the subform and the 300 and 2800. But change the values to what? What do they refer to exactly? The new dimensions I want? And what is an easy way of finding that out?

thanks!
Mar 20 '07 #2
Denburt
1,356 Expert 1GB
The numbers refer to the distance from the edge of your main form (side and bottom), I like to leave a little gap even if nothing is next to it. If you have a control beside or below the subform you may want more distance. I would like to add that anything beside or below it will need to be moved as well so the resizing of the subform doesn't overlap.

Expand|Select|Wrap|Line Numbers
  1. Me!MyButtonUnder.top = Me!MySubform.top+Me!MySubform.height+300
You can actually change the number, then resize the form and see the results immediately.
Mar 20 '07 #3
Denburt
1,356 Expert 1GB
I should probably have added that the unit of measurement in VBA is Twips.

twip: Unit of measurement that is equal to 1/20 of a point, or 1/1,440 of an inch. There are 567 twips in a centimeter.
Mar 20 '07 #4
AccessIdiot
493 256MB
Do you mean that the numbers refer to the size I want the form to be without the subform visible? Sorry, I guess I'm still not getting it. I tried playing with the numbers, making them really small or really big but I'm not sure how it's resizing.
Mar 20 '07 #5
Denburt
1,356 Expert 1GB
O.K. sry reread your original post the code I supplied earlier is for when it is visible and you resize the main form the subform resizes accordingly.

To set your subform to a specific size you would need to designate that manually. I have never set a subform to height to 0 that I can recall but you can try it.

ME!MySubform.Height=0
ME!MySubform.Width=0
After resizing the subform then you can set the size of the main form so you dont see a big blank space.
Me.height = 1440 '1 inch

Once you want to show the subform then you would make it visible again.

ME!MySubform.Height=2880
ME!MySubform.Width=2880
Mar 20 '07 #6
NeoPa
32,556 Expert Mod 16PB
I don't think you can resize a form to be any smaller than it would need to be to handle the existing controls on it (Any more than you can do this as a designer when you have the form open in Design View).
I'm fairly sure that would not be a practical solution for your requirements. It's always good to get ideas from various sources though. Sometimes an idea that may not work for one thing can reap dividends later in another situation.
I'll go back to the other thread to consider what can be done.
Mar 20 '07 #7
AccessIdiot
493 256MB
Yes I'm not sure this works for me. I've been playing with it a bit (sorry I got waylaid but interviewing job applicants) and while it does a great job resizing the subform it does nothing with the space the subform occupies on the form itself.

I guess what I would need is to shrink the form down to just what it would be without a subform when the subform is not visible and then enlarge the form to include the subform when the subform shows.

I'll look into the other code you provided - haven't gotten to it yet.
Mar 20 '07 #8
Denburt
1,356 Expert 1GB
OK I did need to clean it up sry for that.
'you dont need to resize the subform or the detail section but it will remove or reduce the right scrollbar if it is enabled
Me!SubFormName.Height = 0
Me.Section(acDetail).Height = 1440 '1 inch

'This is the size you want your form just adjust the number to suite your needs
Me.InsideHeight = 200


Tried and tested, just adjust the name of the subform and adjust your numbers you should be OK
Mar 20 '07 #9
Denburt
1,356 Expert 1GB
Oh and if you use this in conjunction with the resizing code I posted earlier you will want to check the status of the subform first or the previous post will not do anything.

In the resize section in the VBA you can add a line:

if me!Subform.visible = false then exit sub
Mar 20 '07 #10
AccessIdiot
493 256MB
Okay, I'm sorry, like I said I'm a total noob so I may need some help with actual code here . . . I'm not sure where to put the bits you just added?
Mar 20 '07 #11
Denburt
1,356 Expert 1GB
The following code can be placed in the forms open event.
Expand|Select|Wrap|Line Numbers
  1. 'you dont need to resize the subform or the detail section but it will remove or reduce the right scrollbar if it is enabled
  2. Me!SubFormName.Height = 0
  3. Me.Section(acDetail).Height = 1440 '1 inch
  4.  
  5. 'This is the size you want your form just adjust the number to suite your needs
  6. Me.InsideHeight = 200
  7.  
If you are using the code I provided earlier then you will need to add the following to the beggining of the forms resize event. If not skip this.

Expand|Select|Wrap|Line Numbers
  1. if me!Subform.visible = false then exit sub
  2.  
Mar 20 '07 #12
Denburt
1,356 Expert 1GB
Oh and don't be sorry I was a noob once too! :) Glad to try and help.
Mar 20 '07 #13
AccessIdiot
493 256MB
Thanks for your patience!

I'm going to put this method on hold for now and see if I can get the form/subform to enable/disable using button events. For anyone interested that discussion can be found here:

enable subform with button
Mar 20 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Tony | last post by:
Derived Forms resizing in dotnet. (Fix) Problem: If you have a form base class: public frmBase : System.Windows.Forms { public frmBase { // DefaultFormFont is new Font("Tahoma", 10);
5
by: WJA | last post by:
I'm designing a database which will be the only application used on a touch screen. There are only 2 forms and they are both Modal, Popup and Thin border style. The forms cover the whole screen...
11
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that...
1
by: Terry | last post by:
I've seen several posts from people who have seen this flashing in TreeView's when resizing a form. I've noticed it in my app, but only in the child windows. For example, my main form has a...
8
by: Chris | last post by:
Hi, In design mode I built some windows with some controls (e.g. listboxes, labels, chgeck boxes etc.) in it, and I did set the property for the window size is set to normal. Now, when I run...
11
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
0
by: Sam Barham | last post by:
I have a ListView control, for which I have overwritten the WndProc method to gain access to the WM_PAINT message and generate my own OnPaint and OnPaintBackground messages, in order to colour the...
1
by: Benz. | last post by:
Hello all, I'm having a very strange problem. I've an MDI application with many child forms. In 1 of my Child forms (Say frmA), I've a few design time controls. The forms Autoscroll property is...
2
by: Nina | last post by:
Hi there, I've tried everything that I know to prevent usre resizing datagrid columns, but nothing works. Following are the code that I used. Please tell me what's wrong with them. Thank you....
6
by: JDeats | last post by:
I have a WinForms based application written for the .NET Framework 2.0 and in this application I need to be able to be able to take some action in code when the user finishes resizing the form. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.