473,796 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open many forms from one form

D Giles
11 New Member
Have found many solutions on this forum to get to this point so finally registered.

I have a form which should load 17 forms.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. On Error GoTo Err_Form_Load
  3. DoCmd.Minimize
  4. DoCmd.OpenForm "Reminder Lease Expiry 6mth", acNormal
  5. DoCmd.OpenForm "Reminder Lease Expiry 2mth", acNormal
  6. DoCmd.OpenForm "Reminder Renewal 6mth", acNormal
  7. DoCmd.OpenForm "Reminder Renewal 2mth", acNormal
  8. DoCmd.OpenForm "Reminder Landlord 6mth", acNormal
  9. DoCmd.OpenForm "Reminder Landlord 2mth", acNormal
  10. DoCmd.OpenForm "Reminder Tenant 6mth", acNormal
  11. DoCmd.OpenForm "Reminder Tenant 2mth", acNormal
  12. DoCmd.OpenForm "Reminder Misc 6mth", acNormal
  13. DoCmd.OpenForm "Reminder Misc 2mth", acNormal
  14. DoCmd.OpenForm "Reminder Rent Escalation", acNormal
  15. DoCmd.OpenForm "Reminder Fixed Monthly", acNormal
  16. DoCmd.OpenForm "Reminder Body Corporate Levy", acNormal
  17. DoCmd.OpenForm "Reminder Rent Review", acNormal
  18. DoCmd.OpenForm "Reminder Loan Term Expiry", acNormal
  19. DoCmd.OpenForm "Reminder Loan Repayment", acNormal
  20. Err_Form_Load:
  21. If Err.Number = 2501 Then
  22. DoCmd.Restore
  23. End If
  24. End Sub
The 17 reminder forms run from queries which show reminders past due or as at today's date. If query produces no record the forms close, or if there are due dates sendObject sends the form as an attachment in an email.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. On Error GoTo Err_Form_Open
  3.       If IsNull(Me.Tenant) Then
  4.          Cancel = True
  5. Exit_Form_Open:
  6.          Exit Sub
  7. Err_Form_Open:
  8. If Err.Number = 2501 Then
  9. Resume Exit_Form_Open
  10. End If
  11. Exit Sub
  12. End If
  13. End Sub
  14.  
  15. Private Sub Form_Load()
  16. On Error GoTo Err_Form_Load
  17. DoCmd.SendObject acSendForm, "Reminder Lease Expiry 6mth", acFormatRTF, _
  18.                  "email; email; email; email", "email; email; email", "email", "Tenant Leases: Reminders", , True
  19. Exit_Form_Load:
  20.          Exit Sub
  21. Err_Form_Load:
  22. If Err.Number = 2501 Then
  23. Resume Exit_Form_Load
  24. End If
  25. End Sub
  26.  
This works fine until reaches a form with 0 records which closes, and then it does not run through rest of forms. Any help? thanks.
Jan 25 '08 #1
4 3170
pelicanstuff
24 New Member
I've done something similar for my project - it might not be what you've been looking for, though.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.Visible = False
  3. If DCount("*", "ExpiryQuery1") > 0 Then
  4.     DoCmd.OpenForm "ExpiryForm1", acFormDS, , , acFormReadOnly
  5.  
  6.     Else
  7.         If DCount("*", "ExpiryQuery2") > 0 Then
  8.         DoCmd.OpenForm "Expiryform2", acFormDS, , , acFormReadOnly
  9.  
  10.             Else
  11.             If DCount("*", "ExpiryQuery3") > 0 Then
  12.             DoCmd.OpenForm "ExpiryForm3", acFormDS, , , acFormReadOnly
  13.  
  14.                 Else
  15.                 If DCount("*", "ExpiryQuery4") > 0 Then
  16.                 DoCmd.OpenForm "ExpiryForm4", acFormDS, , , acFormReadOnly
  17.  
  18.                     Else
  19.                     MsgBox "nothing has expired"
  20.  
  21.                 End If
  22.             End If
  23.         End If
  24. End If
  25. Me.Visible = True
  26. End Sub
and then in ExpiryForm1:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2. If DCount("*", "ExpiryQuery2") > 0 Then
  3.         DoCmd.OpenForm "Expiryform2", acFormDS, , , acFormReadOnly
  4.  
  5.             Else
  6.             If DCount("*", "ExpiryQuery3") > 0 Then
  7.             DoCmd.OpenForm "ExpiryForm3", acFormDS, , , acFormReadOnly
  8.  
  9.                 Else
  10.                 If DCount("*", "ExpiryQuery4") > 0 Then
  11.                 DoCmd.OpenForm "ExpiryForm4", acFormDS, , , acFormReadOnly
  12.  
  13.                     Else
  14.                     MsgBox "nothing has expired"
  15.  
  16. End If
  17. End If
  18. End If
  19. End Sub
and so forth for the form_close event of forms 2 and 3, so that the forms run in a cycle, and any with no results gets bypassed. The advantage of this is that you're not opening all the forms at once, but if you did want to, I would imagine the code would look something like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3. If DCount("*", "ExpiryQuery1") > 0 Then
  4. DoCmd.OpenForm "ExpiryForm1", acFormDS, , , acFormReadOnly   
  5. If DCount("*", "ExpiryQuery2") > 0 Then
  6. DoCmd.OpenForm "Expiryform2", acFormDS, , , acFormReadOnly               
  7. If DCount("*", "ExpiryQuery3") > 0 Then
  8. DoCmd.OpenForm "ExpiryForm3", acFormDS, , , acFormReadOnly
  9. If DCount("*", "ExpiryQuery4") > 0 Then
  10. DoCmd.OpenForm "ExpiryForm4", acFormDS, , , acFormReadOnly
  11. End If
  12. End If
  13. End If
  14. End If
  15. End Sub
As you can see, I'm opening the forms as datasheets and read-only, that might not be what you're after.

I'm not so hot with access so feel free to take this with a pinch of salt, but it's something I've just had to do as well.
Jan 25 '08 #2
D Giles
11 New Member
Thanks pelicanstuff for prompt response.
Just doesn't want to work though - stops short each time after first two forms.
Jan 28 '08 #3
D Giles
11 New Member
Thanks pelicanstuff for your prompt response, but I still cant get this to work. I've tried re-arranging the opening order of the Expiry form DoCmds in the main form code, to see where it hangs, and I think it has to do with the Exit or Error handler on the SendObject email sender in the Reminder form code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. On Error GoTo Err_Form_Load
  3. DoCmd.SendObject acSendForm, "Reminder Body Corp Levy", acFormatRTF, _
  4.                  "email; email; email; email", "email; email; email", "email", "Tenant Leases: Reminders", , True
  5. Exit_Form_Load:
  6.          Exit Sub
  7. Err_Form_Load:
  8. If Err.Number = 2501 Then
  9. Resume Exit_Form_Load
  10. End If
  11. End Sub
Any ideas how I should change this? (Access 2003) Thanks.
Jan 28 '08 #4
D Giles
11 New Member
I take it back! Thanks! It works! Maybe took a while to get right because 17 different reminders! Thanks again.
Jan 28 '08 #5

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

Similar topics

55
4678
by: Steve Jorgensen | last post by:
In a recent thread, RKC (correctly, I believe), took issue with my use of multiple parameters in a Property Let procedure to pass dimensional arguments on the basis that, although it works, it's not obvious how the code works if you don't know the intricacies of the Property Let/Get syntax. Likewise, I dislike (and code to minimize the use of) the VB/VBA syntax of returning a value by referring to the function name as if it were a...
3
3787
by: stumorgan | last post by:
There is probably an extremely simple answer to this question and I'm just being foolish. I have a main form (let's say FormMain) which opens other forms (let's say Form1, Form2). How do I keep those created forms, Form1 and Form2, from closing when I close FormMain? Right now what I'm doing is threading them by wrapping the Show method and in that threaded wrapper I have a while loop that just does Application.DoEvents() as long as...
13
2952
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the events.. But the regular forms that are also open do not receive that event. This is true whether there are child forms open or not.
4
2187
by: robert.waters | last post by:
Hello, I have a main form that is maximized when my application loads; this main form contains links to all other forms. I've had to specify the Popup property of these other forms, so that they are not maximized when they load. Unfortunately, this seems to have had the consequence of removing them from the Windows taskbar, which makes navigating between open forms more difficult. How would you developers deal with navigation between...
6
2660
by: Bob Alston | last post by:
Looking for someone with experience building apps with multiple instances of forms open. I am building an app for a nonprofit organizations case workers. They provide services to the elderly. so far I have built a traditional app, switchboard, forms, etc. Part of this app is to automate the forms they previously prepared manually. After the app was built and works just fine, I find out there are several case managers using MS word...
13
3553
by: robert.waters | last post by:
Do you have your users rely on the windows taskbar to manage/navigate between the forms they have open, or do you provide another (more robust) method? Does anyone use a custom navigation system (like keeping a selectable list of open forms in a listbox/commandbar/ breadcrumb trail etc.)?
10
1976
waynetheengineer
by: waynetheengineer | last post by:
Hi, I'm trying to write code for a form when it closes. It's supposed to requery a combo box depending on which form is currenlty open in the background behind the current form, shown below: Private Sub Form_Close() If Forms(frmProjecTotal).CurrentView <> 0 Then Forms!!.Requery Else Forms!!.Requery
19
19045
by: =?Utf-8?B?R3JlZw==?= | last post by:
How can I tell via code if a Form is already open. Each time my forms load I have some initialization code that runs, but if the form is already open and hidden I don't want that initialization code to run. Thus, I just want to unhide the form. My thought is eveyrtime I go to load a form I could scan through all the open forms in my project and determine whether the one I'm getting ready to load is open or not.
4
2692
by: nottarealaddress | last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work after officially stopping new development in VB6 about a month ago). I'm working with a simple sql 2005 table of 50 entries, one for each state. Each entry contains Name, postal abbreviation, etc. Just simple stuff to understand the mechanisms, syntax, etc. I'm now to the point where I've got a Master MDI form that opens one or more types of forms, I'm able to edit/save...
9
3408
by: vanlanjl | last post by:
Okay lets see if I can do this with out confusing myself or others. First I will give ALL the details then state my problem and request at the bottom. Tables: tblContacts ID Company LastName FirstName Initial
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.