changing value of textbox with checkbox option

  • Thread starter Thread starter Haroon
  • Start date Start date
H

Haroon

hi

i have a form with a check box and textbox, when user ticks the checkbox, in
textbox i want todays date to appear.

anyone know how i can do that? is this possible?

cheers.
 
Haroon

That may be more work that you need to do.

What about the idea of allowing the user to double-click the textbox to load
in today's date?

Either way, you'd need to use a related event procedure, but by using the
double-click event, you don't need the extra checkbox control.

Create a new event procedure for the Double-Click event, add something like:

Me!YourTextboxControl = Date()

If you need date/time, use "=Now()"

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Put this code in the checkbox's After Update event proc:

if myCheckBox then 'put the checkbox control name here
myTextBox = Date() ' this is the name of your text box
else
myTextBox = null
end if
 
Try putting some code in the OnChange event of the checkbox:


If Me.CheckBoxName = True Then
Me.TextBoxName = Format(Now(), "mm/dd/yyyy")
End If


--
Jack Leach
www.tristatemachine.com

- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain
 
Use the AfterUpdate event of the checkbox to run code similar to this:

Private Sub NameOfCheckbox_AfterUpdate()
Select Case Me.NameOfCheckbox.Value
Case True
Me.NameOfTextbox.Value = Date()
' if you don't want to overwrite a value that is already in the
textbox,
' then use this next code step instead of the one above
'If Len(Me.NameOfTextbox.Value & vbNullString) = 0 Then _
' Me.NameOfTextbox.Value = Date()
Case False
' put code here to do something when checkbox is unchecked
End Select
End Sub
 
Back
Top