Checkbox - date link

Mabuya

Registered User.
Local time
Today, 21:39
Joined
Nov 21, 2006
Messages
12
Hello,

I've some checkboxes in my database wich need to have a date bound to it, so when i check a box that the date on wich it got checked appears, if the checkbox is not checked the date field should be blank.

Many thanks in advance..
 
use the afterupdate event of the check box to add the date to your date field. you may want to check the field is empty first though to prevent it being changed.

peter
 
I have the need to make clients inactive, they leave us but we still need to hold the information for the authorities, so to stop them being deleted, we just make the record inactive.

Remember to make sure you have the neccessary field set in the table/form to put the date. It checks to see if a date has already been inserted, if it has, it leaves it alone which is something I think you need as well.

On the main form, I have the 'Active' tick box, and a button beside it. when I click the button, it first of all asks if the user does want to make the client inactive. It sets the 'yes/no' field to no and inserts a date in to a field.

Heres the code, there is probably a better way of doing it, but this is what I learnt and it works, so I am not going to argue.

Private Sub ClientInactive_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you really want to make this client inactive? You will not be able to make this client active again!"
Style = vbYesNo + Critical + vbDefaultButton2
Title = "Inactive Client"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
Forms![frmclientmain]![DateUnactive] = Date
Forms![frmclientmain]![Active] = False

Else ' User chose No.
End If
 
Bat17 said:
use the afterupdate event of the check box to add the date to your date field. you may want to check the field is empty first though to prevent it being changed.

peter

Well i tried, i've put in the following expression:
=If([Packaging_in_progress]=True,[Date_pip]="Date()")

It didn't work :(, tried some other expressions, they also didnt work.
 
you need the code in the forms module not in the property sheet :)

from the drop box for the afteraupdate event in the property sheet, select [Event Procedure] and hit the build button ... and build your code.

You should end up with something like: -
Code:
Private Sub Packaging_in_progress_AfterUpdate()
If Me.Packaging_in_progress = True Then
    Me.Date_pip = Date
End If
End Sub

HTh

Peter
 
Thanks alot for the help it worked great !!! :D
 

Users who are viewing this thread

Back
Top Bottom