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

Date Stamp on checkbox

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
7 3655
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
"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
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
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
"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
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance,...
5
by: Adrian | last post by:
Hi I have a vb.net app asp.net 1.1 that uses "NOW" to get the date and the uses a sql statement to write it to an MS SQL server remotely hosted! Well the date has flipped to 13/01/2006 the data...
6
by: Mike Charney | last post by:
Is there a way to check a files date and time stamp from VBA in access. I have a need check a date stamp on a file that I am importing. Thanks in advance, Mike m charney at dunlap hospital...
5
by: Des | last post by:
I have to do an events calender for a church. The events display will be limited to that week. If someone went in today Wed 24th I want to display 21st to 27th. I dont want any code samples, just...
3
by: phried1 | last post by:
I have created a form and inserted the following tables: Date Entered Time Entered Date Modified Time Modified Essentially how and where can I have these dates and times recorded so when the...
1
MitchR
by: MitchR | last post by:
I have created a text box and scripted it to receive a line of text and current date upon completion of a scripted event. My question is this. I need to script this text box and date stamp to...
4
by: andrewbda | last post by:
I have tickbox on a form, and I would like to use a date field as the control source. i.e. I would like to have it display as ticked when a date exists in the field, and vice versa. Also,...
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.