Autopopulate field

SantasLittleHelper

Board Regular
Joined
Nov 25, 2016
Messages
77
Is it possible to have a field on a form automatically display the current date when a tick box is ticked?

e.g. There is a tick box to show whether someone has sent a package out to a customer. When the 'Package Sent' tick box is checked, I would like the 'Package Sent Date' to display the date in which it was ticked.
 
Last edited:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
In my code I have kept the default names (checkbox1 and textbox1)

It will also empty the textbox should you untick the option, this is code against the tickbox

Code:
Private Sub CheckBox1_Click()
    If CheckBox1.Value = True Then
    TextBox1.Value = Format(Now, "dd/mm/yyyy")
    ElseIf CheckBox1.Value = False Then
    TextBox1.Value = ""
    End If
End Sub
 
Last edited:
Upvote 0
Just got to a machine with Access (2010) and tried the code above, changed fieldnames slightly to match my test file and it works - woohoo!

Option Compare Database

Private Sub Field1_Click()
If Field1.Value = True Then
Text1.Value = Format(Now, "dd/mm/yyyy")
ElseIf Field1.Value = False Then
Text1.Value = ""
End If
End Sub
 
Upvote 0
i did think the idea was only to capture the date for the tick box, so
check if date is empty, if not exit sub as it has been previously updated
check for a tick and if it exists then add the date for now value and exit sub, therefore it should only complete once and never be changed
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,563
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top