473,461 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3661
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.