Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   Contact   Join   Order   Logon  
Home > Forums > Access
Access Forum

Welcome to the Microsoft Access Forum. Access is by far our most popular topic here at Computer Learning Zone. This forum is for everyone to read but only students can post here. If you'd like to become a student, all you have to do is enroll in one of my courses, which you can do for as little as $1. After you create a logon, you will have full access to the Forums.

Subscribe to this forum and receive an email update whenever new posts are added. You will also be notified by email if any conversations you are involved in receieve new comments. Yes, even non-students can subscribe to update notifications.

NEW: Access Developer Students, make sure you subscribe to the Developer Student Forum.

Click Here to Post a comment and start a new discussion

Please read the FORUM RULES before posting.


AfterUpdate Event Coding Upload Images   Link 
Mark Hanstad 
2 months ago
How would I code the following:

I have a form with two fields -- Purchase Date   and Refill date

Also, I have two checkboxes
1. 30 Day Refill Date = yes/no
2. 90 Day Refill Date  yes/no

when checkbox value is reached add 30 or 90 to Purchase Date  

Needed calculation:

Refill Date = checkbox value (30 Day Refill Date or 90 Day Refill Date) Purchase Date   + 30 or 90
Adam Schwanz
2 months ago
What do the checkboxes do? So if you bought your prescription 7/1 and then on 7/31 when you came for your 30 day refil you just want to check the 30day refil checkbox and update the refill date? If so just put an after update refilldate = purchasedate + 30. If you are going to continue to push the button more than once, maybe say if refilldate - purchasedate > 30 then refilldate = refilldate + 30 else refilldate = purchasedate + 30
Mark Hanstad
2 months ago
once a prescription is purchased 7/1/21  and the checkbox is checked for a 30 Day Refill Date, I want the Refill date to show 8/1/21.

for a 90 day script of a purchased date of 7/1/21, and the checkbox is checked for a 90 Day Refill Date, I want the Refill date to show 10/1/21.

does that help?
Adam Schwanz
2 months ago
Ok yea, so if its just that simple all you need is an after update event on the 30day checkbox that says refilldate = purchasedate+30 then on the 90 day checkbox do refilldate=purchasedate + 90

If you mark the checkbox before hand and then put the purchase date after. You can put an after update event on the purchasedate field that says
If 30daycheckbox = true then
Elseif 90daycheckbox = true then
End if

You might also want to error check it so you cant have both marked and instead say if 30daycheckbox=true and 90daycheckbox=false kind of thing, then add in if scenario for if both are false or both are true to msgbox something to fix the checkboxes first and exit sub.
Richard Rost
2 months ago
This assumes it's one or the other. Could they get both a 30 day and 90 day refill? :)
Mark Hanstad
2 months ago
Sorry to bother tou again.

I am getting a compile error syntax error

If 30daycheckbox n= true then  (this is the line starting with 30daycheckbox I get the error. Its in Red, it not sure what to do)
Elseif 90daycheckbox = true then  (this is the line starting with 30daycheckbox I get the error. Its in Red, it not sure what to do)
End if

I tried the folwing with the same error. just changed purchasedate to pickup
Private Sub Ctl30DayRefiillDate_AfterUpdate()
If 30DayRefillDate =true then
  Refill Date = Pickup + 30
End If
End Sub

Private Sub Ctl90DayRefiillDate_AfterUpdate()
if 90DayRefillDate = true then
  RefillDate = Pickup + 90
End If
End Sub

Richard Rost
2 months ago
Hi Mark. You've got a bunch of typos in there. Your variable and/or field names shouldn't have spaces in them. I see a couple of them, like "30daycheckbox n" and "Refill Date". You may want to watch my Intro to VBA video before trying to tackle this one.

You may want to go with a simpler, non programming solution. In your RefillDate text box, set the Control Source to this:


That's it. Of course replace "90DayRefill" with whatever the name of your check box is. Basically if the user checks the 90 day box, they will get 90 days, otherwise 30 days.

Sometimes the IIF Function is better for simple things like this, especially for Beginners.
Mark Hanstad
2 months ago
Richard, thank you for your last response... it worked
Add a Reply

Show All Comments

Start a NEW Conversation
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.

You may want to read these articles from the 599CD News:

10/10/2021Copy Text from Field
10/10/2021Access for Free
10/8/2021Label Resize
10/2/2021Criticisms of Access
10/1/2021Access Developer 32
9/28/2021Track Log On

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Account Login
Online Theater
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Keywords: microsoft access forum  PermaLink