473,396 Members | 1,785 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,396 software developers and data experts.

How To Get Access to Autofill Date Field From Past Date

I enter my expense records AFTER a month is gone. What I want to be able to do is once I enter a date the next record's date auto fills next day's date. For eg. I entered first date as Dec 1, 2016, the next record date auto fills Dec 2, 2016 and so on.

Please give as much detail as possible, I have working knowledge of Access but I'm no expert.
Thanking you in advance for help!
Jan 5 '17 #1
1 942
PhilOfWalton
1,430 Expert 1GB
Assuming you have a field called "ExpenseDate" in a table called "TblExpenses" then this code gets the maximum date

Expand|Select|Wrap|Line Numbers
  1. LastDate = DMax("ExpenseDate", "TblExpenses")
  2.  
We now wish to add 1 day to this date so use
Expand|Select|Wrap|Line Numbers
  1. NextDate = DateAdd("d", 1, LastDate)
  2.  
(The 1 means add 1 and "d" means day - so add 1 day)

Putting the whole thing together, when you start to add the new record the Before Insert Sub fires so on the form's Before Insert you need the following
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub Form_BeforeInsert(Cancel As Integer)
  5.  
  6.     ExpensDate.DefaultValue = DateAdd("d", 1, DMax("ExpenseDate", "TblExpenses"))
  7.  
  8. End Sub
  9.  
Phil
Jan 5 '17 #2

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

Similar topics

3
by: andrew | last post by:
Hi: I am already using TreeMap to massage records in my export file such that each record has a unique key combination ( LastName + FirstName + Member Key) . Thus I am sorting the records by...
2
by: buck | last post by:
I'm working on a helpdesk database - does anyone know how to auto enter the date in a new record; would it be soemthing like iif field is null auto enter?
1
by: CZ | last post by:
Hello, I have a list of employees with their birhtdays. I would like to to have a datagrid list employees with birthdays on the current month on a web page. I tried select * from tbldate...
1
by: Graham Feeley | last post by:
I have a date field named rcdate it is a general date eg: 12/08/2006 3:30:00 PM 12/08/2006 3:00:00 PM I used to update another empty field named rdate with the with using in a update query "...
10
by: satishrajana | last post by:
Hi, My SQL returns a NULL in a datefield if there is no date in that field. If there is a NULL in this column, I want to replace it with spaces in my SELECT statement when I am selecting these...
3
by: Finn Stampe Mikkelsen | last post by:
Hi I have defined a table in my database, with 2 date-fields. I have set a default value to DBNull. I have integrated a nullable datetimepicker control to my project and set the apropriate...
10
by: Jes | last post by:
Dear all I have a date field on a HTML form where the user is asked to key in dd/mm/yyyy However, when that is written to MySql it is either not accepted or another value is tored in the...
2
by: Simon | last post by:
Dear reader, The presentation of a date field is possible with short date, long date etcetera. But as you know the presentation of a date field in a report is still be depending on the...
2
by: blees10 | last post by:
Hi Everyone, I have been trying for a while to get this working and it is driving me crazy. I have a subform on a report. On this form, there are 2 fields, tax_id and tax_date. The date is...
2
by: hrprabhu | last post by:
I have a form with a date field and a transaction number field. The transaction number is of the format 99678*06*10*01234. The first five digits (99678) are source code. The next two digits (06)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.