By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

Date Stamp on checkbox

P: n/a
I have a check box called Loadtxt and when it is ticked I want the value of
a control called EmailDatetxt to be today's date. I am using this code in
the AfterUpdate event of the checkbox but it doesn't work.
If Me.Loadtxt = True Then
Me.EmailDatetxt.Value = Date
Else
Me.EmailDatetxt = Null
End If

Anyone any ideas?
TIATony Williams
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Wed, 7 Jan 2004 13:23:54 +0000 (UTC), "Tony Williams"
<tw@tcp.invalid> wrote:

It worked for me (in Access 2000).
Perhaps your code is not connected to the event. Get the properties
for the checkbox, and ensure the AfterUpdate event has [Event
Procedure] listed, and that the code window opens to your code when
you click the ... button to the right of the event.

By the way, the convention is to use prefixes rather than suffixes for
control names, and to have them be different for checkboxes and text
fields:
chkLoad
txtEmailDate

-Tom.
If Me.Loadtxt = True Then
Me.EmailDatetxt.Value = Date
Else
Me.EmailDatetxt = Null
End If


Nov 12 '05 #2

P: n/a
"Tony Williams" <tw@tcp.invalid> wrote in message
news:bt**********@hercules.btinternet.com...
I have a check box called Loadtxt and when it is ticked I want the value of a control called EmailDatetxt to be today's date. I am using this code in
the AfterUpdate event of the checkbox but it doesn't work.
If Me.Loadtxt = True Then
Me.EmailDatetxt.Value = Date
Else
Me.EmailDatetxt = Null
End If

Anyone any ideas?
TIATony Williams


I see no reason why that doesn't work and you don't say what does actually
happen. It may be that the code is no longer associated with the control
(this can happen when you are designing the form, re-naming controls, etc).
To check this, look at the form in design view and double-click the
check-box to view its properties, find the AfterUpdate event in the event
tab and click the ... to make sure this takes you to the code you think it
should. Next, make sure the code compiles and close your form saving any
changes.

Perhaps you would like to consider a standard naming convention for your
controls such as chkLoad for a checkbox and txtDate for a textbox. This
convention helps to make sure you don't have forms that have identical field
and control names which can cause confusion (but is how Access names its
controls by default).

Also, although not really necessary here you could have a standard
error-handling procedure so all of these subs that you write for the form's
controls all look, well ..., more standard. Eg

Private Sub chkLoad_AfterUpdate()

On Error GoTo Err_Handler

If Me.chkLoad = True Then
Me.txtEmailDate = Date
Else
Me.txtEmailDate = Null
End If

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub


Nov 12 '05 #3

P: n/a
Hello again Fletcher you've helped me before! I expected the date control to
be filled with today's date but I get an error message that says "Access
can't find the field Date" I thought Date was a VB function? I don't have
any fields called Date

Any ideas?

Thanks for the tip about naming and error codes presumably I can add the
code you gave me to any of the subs?

TIA

Tony

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bt**********@sparta.btinternet.com...
"Tony Williams" <tw@tcp.invalid> wrote in message
news:bt**********@hercules.btinternet.com...
I have a check box called Loadtxt and when it is ticked I want the value of
a control called EmailDatetxt to be today's date. I am using this code in the AfterUpdate event of the checkbox but it doesn't work.
If Me.Loadtxt = True Then
Me.EmailDatetxt.Value = Date
Else
Me.EmailDatetxt = Null
End If

Anyone any ideas?
TIATony Williams


I see no reason why that doesn't work and you don't say what does actually
happen. It may be that the code is no longer associated with the control
(this can happen when you are designing the form, re-naming controls,

etc). To check this, look at the form in design view and double-click the
check-box to view its properties, find the AfterUpdate event in the event
tab and click the ... to make sure this takes you to the code you think it
should. Next, make sure the code compiles and close your form saving any
changes.

Perhaps you would like to consider a standard naming convention for your
controls such as chkLoad for a checkbox and txtDate for a textbox. This
convention helps to make sure you don't have forms that have identical field and control names which can cause confusion (but is how Access names its
controls by default).

Also, although not really necessary here you could have a standard
error-handling procedure so all of these subs that you write for the form's controls all look, well ..., more standard. Eg

Private Sub chkLoad_AfterUpdate()

On Error GoTo Err_Handler

If Me.chkLoad = True Then
Me.txtEmailDate = Date
Else
Me.txtEmailDate = Null
End If

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub

Nov 12 '05 #4

P: n/a
Thanks Tom. I'm getting an error message that says "Access can't find the
field Date" I thought Date was a function and I haven't got a field called
date?
Tony
"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:3s********************************@4ax.com...
On Wed, 7 Jan 2004 13:23:54 +0000 (UTC), "Tony Williams"
<tw@tcp.invalid> wrote:

It worked for me (in Access 2000).
Perhaps your code is not connected to the event. Get the properties
for the checkbox, and ensure the AfterUpdate event has [Event
Procedure] listed, and that the code window opens to your code when
you click the ... button to the right of the event.

By the way, the convention is to use prefixes rather than suffixes for
control names, and to have them be different for checkboxes and text
fields:
chkLoad
txtEmailDate

-Tom.
If Me.Loadtxt = True Then
Me.EmailDatetxt.Value = Date
Else
Me.EmailDatetxt = Null
End If

Nov 12 '05 #5

P: n/a
"Tony Williams" <tw@tcp.invalid> wrote in message
news:bt**********@titan.btinternet.com...
Hello again Fletcher you've helped me before! I expected the date control to be filled with today's date but I get an error message that says "Access
can't find the field Date" I thought Date was a VB function? I don't have
any fields called Date

Any ideas?

Thanks for the tip about naming and error codes presumably I can add the
code you gave me to any of the subs?

TIA

Tony

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bt**********@sparta.btinternet.com...
"Tony Williams" <tw@tcp.invalid> wrote in message
news:bt**********@hercules.btinternet.com...
I have a check box called Loadtxt and when it is ticked I want the
value
of
a control called EmailDatetxt to be today's date. I am using this code in the AfterUpdate event of the checkbox but it doesn't work.
If Me.Loadtxt = True Then
Me.EmailDatetxt.Value = Date
Else
Me.EmailDatetxt = Null
End If

Anyone any ideas?
TIATony Williams


I see no reason why that doesn't work and you don't say what does

actually happen. It may be that the code is no longer associated with the control (this can happen when you are designing the form, re-naming controls,

etc).
To check this, look at the form in design view and double-click the
check-box to view its properties, find the AfterUpdate event in the event tab and click the ... to make sure this takes you to the code you think it should. Next, make sure the code compiles and close your form saving any changes.

Perhaps you would like to consider a standard naming convention for your
controls such as chkLoad for a checkbox and txtDate for a textbox. This
convention helps to make sure you don't have forms that have identical

field
and control names which can cause confusion (but is how Access names its
controls by default).

Also, although not really necessary here you could have a standard
error-handling procedure so all of these subs that you write for the

form's
controls all look, well ..., more standard. Eg

Private Sub chkLoad_AfterUpdate()

On Error GoTo Err_Handler

If Me.chkLoad = True Then
Me.txtEmailDate = Date
Else
Me.txtEmailDate = Null
End If

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub


Hi Tony
Yes I remember our previous exchange on generating new numbers. Hope things
are going well (apart from this current difficulty).

It's interesting to note that Tom van Stiphout's post was pretty similar to
mine. That is (a) this should in theory work (b) use a naming convention
and (c) the code might have become detached.
My advice now (assuming you don't have millions of lines of code) is to cut
*all of the code* from the form's module and place it in a small .txt file.
Close the form and save changes. Then rename each of the controls to a
standard form e.g. txtTextBox, cboComboBox, chkCheckBox, cmdCommandButton,
etc. Then by going to the event properties of each control click the ...
and re-enter the code. You can do some cutting and pasting from the text
file, but make sure to make any name changes.

Finally, while looking at your code select Tools>References and make sure
none of these are missing. Then choose Debug>Compile to make sure all of
your code compiles. If after all this, you still can't get it to work, you
could e-mail it to me if you kept my address.

HTH
Fletcher
Nov 12 '05 #6

P: n/a
Thanks Fletcher I'll try that. Got to pack up now but I'll try it on Friday
out tomorrow.
Number generating works fine had to tweak it a bit to fit my application but
works well
Thanks again
Tony
"Fletcher Arnold" <fl****@home.com> wrote in message
news:bt**********@hercules.btinternet.com...
"Tony Williams" <tw@tcp.invalid> wrote in message
news:bt**********@titan.btinternet.com...
Hello again Fletcher you've helped me before! I expected the date control
to
be filled with today's date but I get an error message that says "Access
can't find the field Date" I thought Date was a VB function? I don't have any fields called Date

Any ideas?

Thanks for the tip about naming and error codes presumably I can add the
code you gave me to any of the subs?

TIA

Tony

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bt**********@sparta.btinternet.com...
"Tony Williams" <tw@tcp.invalid> wrote in message
news:bt**********@hercules.btinternet.com...
> I have a check box called Loadtxt and when it is ticked I want the value of
> a control called EmailDatetxt to be today's date. I am using this code in
> the AfterUpdate event of the checkbox but it doesn't work.
> If Me.Loadtxt = True Then
> Me.EmailDatetxt.Value = Date
> Else
> Me.EmailDatetxt = Null
> End If
>
> Anyone any ideas?
> TIATony Williams

I see no reason why that doesn't work and you don't say what does actually happen. It may be that the code is no longer associated with the control (this can happen when you are designing the form, re-naming controls, etc).
To check this, look at the form in design view and double-click the
check-box to view its properties, find the AfterUpdate event in the event tab and click the ... to make sure this takes you to the code you
think it should. Next, make sure the code compiles and close your form saving any changes.

Perhaps you would like to consider a standard naming convention for
your controls such as chkLoad for a checkbox and txtDate for a textbox. This convention helps to make sure you don't have forms that have identical

field
and control names which can cause confusion (but is how Access names its controls by default).

Also, although not really necessary here you could have a standard
error-handling procedure so all of these subs that you write for the

form's
controls all look, well ..., more standard. Eg

Private Sub chkLoad_AfterUpdate()

On Error GoTo Err_Handler

If Me.chkLoad = True Then
Me.txtEmailDate = Date
Else
Me.txtEmailDate = Null
End If

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub


Hi Tony
Yes I remember our previous exchange on generating new numbers. Hope

things are going well (apart from this current difficulty).

It's interesting to note that Tom van Stiphout's post was pretty similar to mine. That is (a) this should in theory work (b) use a naming convention
and (c) the code might have become detached.
My advice now (assuming you don't have millions of lines of code) is to cut *all of the code* from the form's module and place it in a small .txt file. Close the form and save changes. Then rename each of the controls to a
standard form e.g. txtTextBox, cboComboBox, chkCheckBox, cmdCommandButton,
etc. Then by going to the event properties of each control click the ...
and re-enter the code. You can do some cutting and pasting from the text
file, but make sure to make any name changes.

Finally, while looking at your code select Tools>References and make sure
none of these are missing. Then choose Debug>Compile to make sure all of
your code compiles. If after all this, you still can't get it to work, you could e-mail it to me if you kept my address.

HTH
Fletcher

Nov 12 '05 #7

P: n/a
> Thanks Tom. I'm getting an error message that says "Access can't find the
field Date" I thought Date was a function and I haven't got a field called
date?


If you find that this isn't a references problem, you might try simply adding
the "()" in the call to the "Date" function:

Me.EmailDatetxt.Value = Date()

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.