Greetings,
1. I have a main form called Household and a subform called Applicants. In the main form I have NumOfApp field, where I would like to automatically be filled depending on how many people applied in the Applicants form.
2. Also, I have DateReceived and DateDue fields in the Applicants form.
The DateDue is calculated by adding 10 workdays(DateReceived + 9) to the
DateReceived and put the result into DateDue field automatically.
So the user don
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Subform/Calculations (Win 2000)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Subform/Calculations (Win 2000)
- This topic has 8 replies, 3 voices, and was last updated 22 years, 2 months ago.
AuthorTopicWSOCM
AskWoody LoungerMarch 27, 2003 at 8:54 pm #385378Viewing 2 reply threadsAuthorReplies-
WSHansV
AskWoody LoungerMarch 27, 2003 at 9:35 pm #6645551. You can put a text box on the main form and set its Control Source property to
=[Applicants].[Form].[RecordsetClone].[RecordCount]
Replace Applicants by the name of the subform as a control on the main form; this is not necessarily the same as the name of the subform in the database window.
-
WSpatt
AskWoody LoungerMarch 27, 2003 at 9:36 pm #664556I’ll answer q2, look at post 239080.
You could use post 238855 with modifcations.
Pat -
WSHansV
AskWoody LoungerMarch 27, 2003 at 9:41 pm #6645592. What is the question? How to add a number of workdays to a given date? Here are two functions you can use for this. These functions don’t take holidays into account. There are several recent threads about holidays; if you do a search for holiday, you’ll find them. Added: Patt has posted some links in the meantime.
‘ The NextWorkday function returns the first workday (not Saturday or Sunday) after aDate.
Function NextWorkday(aDate As Date) As Date
Dim d As Date
d = aDate + 1
Do While WeekDay(d) = vbSunday Or WeekDay(d) = vbSaturday
d = d + 1
Loop
NextWorkday = d
End Function‘ The WorkdayAdd function returns the date aNumber workdays (not Saturday or Sunday) after aDate.
‘ Example: WorkdayAdd(#10/18/02#, 4) returns #10/24/02#.Function WorkdayAdd(aDate As Date, aNumber As Long) As Date
Dim d As Date
Dim i As Long
d = aDate
For i = 1 To aNumber
d = NextWorkday(d)
Next i
WorkdayAdd = d
End FunctionYou can use this function to calculate DateDue:
=WorkdayAdd([DateReceived],9)
-
WSHansV
AskWoody LoungerMarch 31, 2003 at 7:39 pm #665361More about 2:
You need both functions, because the second (WorkdayAdd) uses the first (NextWorkday). You should copy both functions into a new module in the database. Save the module as – for example – basDateFunctions.
One possibility is *not* to have a field DateDue in the table at all, but to make it a calculated field in a query based on the table. That way, DateDue will always be up-to-date. The expression for DateDue in the query would be
DateDue:WorkdayAdd([DateReceived],9)
You can use this on a form the same way you can use a field in the table. The major difference is that a calculated field is not editable by the user.
If you need DateDue to be a field in the table, you must update it whenever DateReceived is updated. You can only do this on a form, not in the table itself.
- Open the form based on your table in design view.
- Select the control bound to DateReceived.
- Make sure that the Properties window is visible (View/Properties).
- Activate the Events tab of the Properties window.
- Click in the After Update event.
- Select Event Procedure from the dropdown list.
- Click the Builder button (the three dots to the right)
- You get an empty even procedure. Complete it so that it looks as follows:
Private Sub DateReceived_AfterUpdate()
DateDue = WorkdayAdd(Me.DateReceived,9)
End SubIf necessary, replace DateReceived and DateDue by the actual names of the controls on your form bound to DateReceived and DateDue.
[/list]HTH
-
WSOCM
AskWoody LoungerApril 10, 2003 at 1:43 pm #667742Thanks for your reply Hans,
The workdayAdd part works fine. A similar question though, I have two combo boxes (AppStatus with drop down NEW, REDETERM etc & EligStatus with drop down ELIG, DENIED etc) depending on what the user selects from each field, EligDays = the difference between two fields. For example, if NEW from AppStatus & ELIG from EligStatus selected then EligDays = [AppRec] – [EligDate]. How do I get the result (in work day) automatically to be filled in EligDays field?Thanks,
DD -
WSHansV
AskWoody LoungerApril 11, 2003 at 9:40 pm #667747Private Sub UpdateEligDays()
Dim dteApp As Date
Dom dteElig As DateSelect Case AppStatus
Case “New”
dteApp = AppRec
Case “Redeterm”
…
End SelectSelect Case EligStatus
Case “Elig”
dteElig = EligDate
Case “Denied”
…
End SelectEligDays = dteApp – dteElig
End SubIf you want EligDays to be updated each time the user selects a value from the AppStatus combo and from the EligStatus combo, call this from the AfterUpdate event of both combo boxes. It it’s OK to update only when the user leaves the record, call it from the BeforeUpdate event of the form.
-
WSOCM
AskWoody Lounger -
WSHansV
AskWoody LoungerApril 11, 2003 at 9:58 pm #668059The situation is more complicated than I had guessed from your earlier post (I thought that the combo boxes acted independently of each other in determining which dates to subtract). Although the code could be simplified to some extent, I’d say leave it like it is, with one exception: I would use EligDays = Null instead of EligDays = “” in the last Else clause. Null creates a truly empty value.
(And I would remove the comments, because they don’t say more than the code already does, so they only make the code look cluttered. But that’s just a private opinion.)
-
-
-
-
Viewing 2 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Phishers extract Millions from HMRC accounts..
by
Microfix
2 hours, 57 minutes ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
4 hours, 49 minutes ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
7 hours, 57 minutes ago -
Mystical Desktop
by
CWBillow
8 hours, 11 minutes ago -
Meta and Yandex secretly tracked billions of Android users
by
Alex5723
2 hours, 57 minutes ago -
MS-DEFCON 2: Do you need that update?
by
Susan Bradley
1 hour, 10 minutes ago -
CD/DVD drive is no longer recognized
by
WSCape Sand
23 hours, 23 minutes ago -
Windows 11 24H2 Default Apps stuck on Edge and Adobe Photoshop
by
MikeBravo
1 day, 2 hours ago -
North Face and Cartier customer data stolen in cyber attacks
by
Alex5723
1 day ago -
What is wrong with simple approach?
by
WSSpoke36
16 hours, 50 minutes ago -
Microsoft-Backed Builder.ai Set for Bankruptcy After Cash Seized
by
Alex5723
1 day, 11 hours ago -
Location, location, location
by
Susan Bradley
2 hours, 9 minutes ago -
Cannot get a task to run a restore point
by
CWBillow
1 day, 13 hours ago -
Frustrating search behavior with Outlook
by
MrJimPhelps
1 day, 3 hours ago -
June 2025 Office non-Security Updates
by
PKCano
1 day, 23 hours ago -
Secure Boot Update Fails after KB5058405 Installed
by
SteveIT
2 hours, 30 minutes ago -
Firefox Red Panda Fun Stuff
by
Lars220
1 day, 23 hours ago -
How start headers and page numbers on page 3?
by
Davidhs
2 days, 10 hours ago -
Attack on LexisNexis Risk Solutions exposes data on 300k +
by
Nibbled To Death By Ducks
1 day, 12 hours ago -
Windows 11 Insider Preview build 26200.5622 released to DEV
by
joep517
2 days, 18 hours ago -
Windows 11 Insider Preview build 26120.4230 (24H2) released to BETA
by
joep517
2 days, 18 hours ago -
MS Excel 2019 Now Prompts to Back Up With OneDrive
by
lmacri
2 days, 8 hours ago -
Firefox 139
by
Charlie
2 days, 1 hour ago -
Who knows what?
by
Will Fastie
1 day, 3 hours ago -
My top ten underappreciated features in Office
by
Peter Deegan
2 days, 19 hours ago -
WAU Manager — It’s your computer, you are in charge!
by
Deanna McElveen
13 hours, 16 minutes ago -
Misbehaving devices
by
Susan Bradley
1 day, 15 hours ago -
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
4 days, 1 hour ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
1 day ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
4 days ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.