Have found many solutions on this forum to get to this point so finally registered.
I have a form which should load 17 forms. - Private Sub Form_Load()
-
On Error GoTo Err_Form_Load
-
DoCmd.Minimize
-
DoCmd.OpenForm "Reminder Lease Expiry 6mth", acNormal
-
DoCmd.OpenForm "Reminder Lease Expiry 2mth", acNormal
-
DoCmd.OpenForm "Reminder Renewal 6mth", acNormal
-
DoCmd.OpenForm "Reminder Renewal 2mth", acNormal
-
DoCmd.OpenForm "Reminder Landlord 6mth", acNormal
-
DoCmd.OpenForm "Reminder Landlord 2mth", acNormal
-
DoCmd.OpenForm "Reminder Tenant 6mth", acNormal
-
DoCmd.OpenForm "Reminder Tenant 2mth", acNormal
-
DoCmd.OpenForm "Reminder Misc 6mth", acNormal
-
DoCmd.OpenForm "Reminder Misc 2mth", acNormal
-
DoCmd.OpenForm "Reminder Rent Escalation", acNormal
-
DoCmd.OpenForm "Reminder Fixed Monthly", acNormal
-
DoCmd.OpenForm "Reminder Body Corporate Levy", acNormal
-
DoCmd.OpenForm "Reminder Rent Review", acNormal
-
DoCmd.OpenForm "Reminder Loan Term Expiry", acNormal
-
DoCmd.OpenForm "Reminder Loan Repayment", acNormal
-
Err_Form_Load:
-
If Err.Number = 2501 Then
-
DoCmd.Restore
-
End If
-
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. - Private Sub Form_Open(Cancel As Integer)
-
On Error GoTo Err_Form_Open
-
If IsNull(Me.Tenant) Then
-
Cancel = True
-
Exit_Form_Open:
-
Exit Sub
-
Err_Form_Open:
-
If Err.Number = 2501 Then
-
Resume Exit_Form_Open
-
End If
-
Exit Sub
-
End If
-
End Sub
-
-
Private Sub Form_Load()
-
On Error GoTo Err_Form_Load
-
DoCmd.SendObject acSendForm, "Reminder Lease Expiry 6mth", acFormatRTF, _
-
"email; email; email; email", "email; email; email", "email", "Tenant Leases: Reminders", , True
-
Exit_Form_Load:
-
Exit Sub
-
Err_Form_Load:
-
If Err.Number = 2501 Then
-
Resume Exit_Form_Load
-
End If
-
End Sub
-
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.
4 3140
I've done something similar for my project - it might not be what you've been looking for, though. - Private Sub Form_Load()
-
Me.Visible = False
-
If DCount("*", "ExpiryQuery1") > 0 Then
-
DoCmd.OpenForm "ExpiryForm1", acFormDS, , , acFormReadOnly
-
-
Else
-
If DCount("*", "ExpiryQuery2") > 0 Then
-
DoCmd.OpenForm "Expiryform2", acFormDS, , , acFormReadOnly
-
-
Else
-
If DCount("*", "ExpiryQuery3") > 0 Then
-
DoCmd.OpenForm "ExpiryForm3", acFormDS, , , acFormReadOnly
-
-
Else
-
If DCount("*", "ExpiryQuery4") > 0 Then
-
DoCmd.OpenForm "ExpiryForm4", acFormDS, , , acFormReadOnly
-
-
Else
-
MsgBox "nothing has expired"
-
-
End If
-
End If
-
End If
-
End If
-
Me.Visible = True
-
End Sub
and then in ExpiryForm1: - Private Sub Form_Close()
-
If DCount("*", "ExpiryQuery2") > 0 Then
-
DoCmd.OpenForm "Expiryform2", acFormDS, , , acFormReadOnly
-
-
Else
-
If DCount("*", "ExpiryQuery3") > 0 Then
-
DoCmd.OpenForm "ExpiryForm3", acFormDS, , , acFormReadOnly
-
-
Else
-
If DCount("*", "ExpiryQuery4") > 0 Then
-
DoCmd.OpenForm "ExpiryForm4", acFormDS, , , acFormReadOnly
-
-
Else
-
MsgBox "nothing has expired"
-
-
End If
-
End If
-
End If
-
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: - Private Sub Form_Load()
-
-
If DCount("*", "ExpiryQuery1") > 0 Then
-
DoCmd.OpenForm "ExpiryForm1", acFormDS, , , acFormReadOnly
-
If DCount("*", "ExpiryQuery2") > 0 Then
-
DoCmd.OpenForm "Expiryform2", acFormDS, , , acFormReadOnly
-
If DCount("*", "ExpiryQuery3") > 0 Then
-
DoCmd.OpenForm "ExpiryForm3", acFormDS, , , acFormReadOnly
-
If DCount("*", "ExpiryQuery4") > 0 Then
-
DoCmd.OpenForm "ExpiryForm4", acFormDS, , , acFormReadOnly
-
End If
-
End If
-
End If
-
End If
-
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.
Thanks pelicanstuff for prompt response.
Just doesn't want to work though - stops short each time after first two forms.
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: - Private Sub Form_Load()
-
On Error GoTo Err_Form_Load
-
DoCmd.SendObject acSendForm, "Reminder Body Corp Levy", acFormatRTF, _
-
"email; email; email; email", "email; email; email", "email", "Tenant Leases: Reminders", , True
-
Exit_Form_Load:
-
Exit Sub
-
Err_Form_Load:
-
If Err.Number = 2501 Then
-
Resume Exit_Form_Load
-
End If
-
End Sub
Any ideas how I should change this? (Access 2003) Thanks.
I take it back! Thanks! It works! Maybe took a while to get right because 17 different reminders! Thanks again.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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.
...
|
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...
|
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:
...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
|
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...
|
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
|
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...
| |