473,326 Members | 2,076 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,326 software developers and data experts.

Open many forms from one form

D Giles
11
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 3140
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
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
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
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
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...
3
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...
13
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...
4
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...
6
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. ...
13
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...
10
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: ...
19
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...
4
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...
9
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...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.