473,379 Members | 1,344 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,379 software developers and data experts.

Can FormB tell FormA to move/resize?

Greetings all,

I'm working on a database that has a series of forms (FormA, FormB, FormC, FormD). Each time I click a button on one form, it opens the next and moves the original form to the corner of the screen using DoCmd.MoveSize. I did this for purely aesthetic reasons: instead of minimizing the forms or making them invisible, I organize them off-center so their captions show.

Then someone challenged me to return those forms to their original position on the close of the previous form (again, for purely aesthetic reasons). And here is where I ran into some trouble: the DoCmd.MoveSize can be applied to a button click or OnOpen, but that's for the current form. What I was hoping to do was find a way to click a button on FormB that would tell FormA to move to another position/size. Is this feasible?

I messed with the SetFocus command but couldn't make it work. I even rigged it so that on the close of FormB, it closed FormA too and then immediately re-opened FormA (which has its own particular DoCmd.MoveSize parameters OnOpen); however, that only worked when toggling between two forms: remember, if OnClose of FormC, FormB closes and reopens, and if OnClose of FormB, FormA closes and reopens, then, in cascading fashion, the close of FormC will close FormA and reopen it according to its own OnOpen position/size. Besides, that's not what I really want to happen.

Any ideas?

andy
Apr 6 '10 #1

✓ answered by Delerna

set focus to the form you want to resize
before using docmd

Expand|Select|Wrap|Line Numbers
  1.    Private Sub Command1_Click()
  2.       ' This code is on FormB
  3.  
  4.       Forms![FormA].SetFocus
  5.       DoCmd.MoveSize 100, 100, 1000, 1000
  6.       Me.SetFocus
  7.    End Sub
  8.  

3 1945
Delerna
1,134 Expert 1GB
set focus to the form you want to resize
before using docmd

Expand|Select|Wrap|Line Numbers
  1.    Private Sub Command1_Click()
  2.       ' This code is on FormB
  3.  
  4.       Forms![FormA].SetFocus
  5.       DoCmd.MoveSize 100, 100, 1000, 1000
  6.       Me.SetFocus
  7.    End Sub
  8.  
Apr 6 '10 #2
patjones
931 Expert 512MB
Hi -

I'll show you how to do this with two forms; you can apply the procedure to as many forms as you want though.

In the VBA window, go Insert > Module. This will create a new code module. You'll declare two variables in it:

Expand|Select|Wrap|Line Numbers
  1. Dim intLeftFormA As Integer
  2. Dim intTopFormA As integer

These two variables are global; they can be seen by all other modules in your project. In the OnClick event for the button in form A, put

Expand|Select|Wrap|Line Numbers
  1. intLeftFormA = Me.WindowLeft
  2. intTopFormA = Me.WindowTop
  3.  
  4. DoCmd.MoveSize 5, 5
  5. DoCmd.OpenForm "frmB", acNormal
  6.  

The first two lines store the position of the form in the global variables before you move it...for later use. The third line moves form A nearly to the upper-left corner. The fourth line obviously opens form B. In the button on form B that closes form B and will re-position form A, put

Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form
  2. Set frm = Forms!frmA
  3.  
  4. DoCmd.Close acForm, "frmB", acSaveNo
  5. frm.Move intLeftFormA, intTopFormA
  6.  

You have to declare a form object in order to be able to use all the various form methods, which is what the first two lines are about. I tested this out quickly and it seems to work okay. Let me know how it goes!

Pat
Apr 7 '10 #3
Delerna,

Your method worked great! Quick and easy.

Thanks for your help!

andy
Apr 7 '10 #4

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

Similar topics

4
by: Peter Mrosek | last post by:
Hello, I have the following declaration in an header file (abbreviated version): typedef struct { unsigned char rgbBlue; unsigned char rgbGreen; unsigned char rgbRed; unsigned char...
7
by: William Payne | last post by:
(This post is related to "recent files menu"-post below. If I should have kept this in that thread, I apologise.) Hello, I have a function that adds a std::string to a std::vector. New entries are...
1
by: Iwer M?rck | last post by:
Hi How can I move and resize then access application window from within VBA? Best regards Iwer Mørck
3
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the...
12
by: WJ | last post by:
What controls needed to cause the entire page moves along with the "resizing" of the web browser (left/right)? Example: Click here http://www.google.com, when Google main page is displayed in...
0
by: Juan Romero | last post by:
Guys, I am trying to create a move / resize effect by drawing a rectangle on the window when the user is moving a picture box around. The problem I am running into is that when I draw the...
4
by: Rob Richardson | last post by:
Greetings! I have a form with a listview, a menu, and a few text boxes, labels and command buttons. I want to resize the listview when the form is resized to that the widths of the spaces...
2
by: mrbrightsidestolemymoney | last post by:
Hi, I'm having a problem resizing a (very big) nested vector. It's not the most streamlined piece of code ever but I need this array to avoid having to recalculate the same quantity millions of...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
3
by: mukeshsrivastav | last post by:
dear sir i want to move form excel to access. i have 5 excel file having same formats and fields.now i want to import all data in one access table. importing one file is easy .but importing and...
1
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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.