473,395 Members | 2,446 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,395 software developers and data experts.

Automatic Date Entry

Hi,

I have a check box on one of my forms, let call the field "ceased?",
and when it is checked I would like the current date put into my date
field and the "ceased?" field protected.
Would anyone know the code to do this?
Any help would be greatly appreciated
Cheers

Zie

Jan 6 '06 #1
5 2755
Use the AfterUpdate event procedure of the check box to drop the date into
your other field:
Private Sub ceased_AfterUpdate()
If Me.ceased.Value Then
Me.CeasedDate = Date
Else
Me.CeasedDate = Null
End If
End Sub

In the Current event of the form:
Private Sub Form_Current()
Dim bDisabled As Boolean
With Me.ceased
bDisabled = Nz(.Value, False)
If .Enabled = bDisabled Then
.Enabled = Not bDisabled
End If
End With
End Sub

You need to add error handling to Form_Current, to handle the case where the
ceased check box cannot be disabled because it has focus.

The code above will make the ceased check box disabled next time you load
the record in the form once it has been checked.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<z.******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...

I have a check box on one of my forms, let call the field "ceased?",
and when it is checked I would like the current date put into my date
field and the "ceased?" field protected.
Would anyone know the code to do this?
Any help would be greatly appreciated

Jan 6 '06 #2
Your can use this code on the AfterUpdate of the chekbox and use some
code on the current as Allen said.

RetValue = MsgBox("Do you really want to cease?", vbYesNoCancel +
vbExclamation, "Cease")
Select Case RetValue
Case Is = vbNo
Me.Ceased = False
Case Is = vbCancel
Me.Ceased = False
Case Is = vbYes
Me.txtDate = Now()
Me.SomeControl.SetFocus
Me.Ceased.Enabled = False
End Select

GAVO.

Jan 6 '06 #3
z.******@gmail.com wrote:
Hi,

I have a check box on one of my forms, let call the field "ceased?",
and when it is checked I would like the current date put into my date
field and the "ceased?" field protected.
Would anyone know the code to do this?
Any help would be greatly appreciated
Cheers

Zie


The other responses have answered your question, but I thought I would point
out that (it appears) that you have a redundant and unnecessary field in
your table. If all "ceased" records will have a CeaseDate and all records
that are not "ceased" will have a Null in CeaseDate, then you really don't
need the Yes/No field for [ceased] at all. It is telling you the same
information that you can derive by looking at the CeaseDate field.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Jan 6 '06 #4
Red

Rick Brandt wrote:
The other responses have answered your question, but I thought I would point
out that (it appears) that you have a redundant and unnecessary field in
your table. If all "ceased" records will have a CeaseDate and all records
that are not "ceased" will have a Null in CeaseDate, then you really don't
need the Yes/No field for [ceased] at all. It is telling you the same
information that you can derive by looking at the CeaseDate field.


I completely understand that, but try explaining that to non-computer
literate co-workers =P

Jan 7 '06 #5
"Red" <do**********@gmail.com> wrote in
news:11*********************@g14g2000cwa.googlegro ups.com:

Rick Brandt wrote:
The other responses have answered your question, but I
thought I would point out that (it appears) that you have a
redundant and unnecessary field in your table. If all
"ceased" records will have a CeaseDate and all records that
are not "ceased" will have a Null in CeaseDate, then you
really don't need the Yes/No field for [ceased] at all. It
is telling you the same information that you can derive by
looking at the CeaseDate field.


I completely understand that, but try explaining that to
non-computer literate co-workers =P

Since a good rule of database application development is to
never expose the underlying tables or queries to the user, but
to always use forms and reports, the non-computer literates
would never know.
I have many forms where a label displaying "this item is
closed" is on the form but is set in code based on the nullity
of a date field, and not stored in the table..
--
Bob Quintal

PA is y I've altered my email address.
Jan 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gord | last post by:
Hello, VB6 accepts Date and Time values as 'Date'. I'm trying to verify entry into a database I'm creating by verifying that an appropriate Date or Time value has been entered. Using built-in...
4
by: Alistair | last post by:
IIS, Access 2000 I have a page that tabulates data from a DB, this data is items for sale, private ads. is there a way that at the same time it can automatically delete entries that are...
6
by: christopher.secord | last post by:
I have a table containing typed log entries. One log entry is supposed to be created every twelve hours, but sometimes there are gaps. I need to create a report showing the time of entry, and the...
1
by: Alessandro GARDICH | last post by:
Hi to all ... I'm looking to a way to auto update some fields of a row when other fileds are updated. the table structure are simple, CREATE TABLE param ( id int4 PRIMARY KEY, val int4,
1
by: erkwong | last post by:
Hello, What would be the simplist way to get the current date to populate a text box upon the de-selecting of a check-box (aka making the check box field false?) This is basically what I had...
1
by: Prasanth Nair | last post by:
hi, When I add the following in struts-config.xml, I am getting the below mentioned error while starting the server. /***********************Struts entry**********************/ <plug-in...
1
by: Russ Landry | last post by:
Hello, I have created a database, with many fields in the table. Most are static, but there are 48 fields that can be updated via, text, drop downs, check boxs, or direct data entry. I currently...
8
by: ivijayan | last post by:
HI. I have the following query:- How do i create field which updates its contents on the basis of data in another field in same record. especially if I have a Date field, how can I change the...
2
by: DThreadgill | last post by:
Not sure how to begin with this one. My table consists of: Branch# (number, double) EntryDate (datetime, mm/dd/yyyy hh:mm:ss am/pm) One branch can have many entry dates (i.e, Branch # 76...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
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...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.