A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Add a date to a form



 
 
Thread Tools Display Modes
  #1  
Old March 4th, 2008, 05:03 PM posted to microsoft.public.access.forms
AlastairO
external usenet poster
 
Posts: 2
Default Add a date to a form

I am wanting to add a CreateDate to a form which enters the date from the
computer system but doesn't update the next day.

Any helpers please!

Thanks

Alastair
  #2  
Old March 4th, 2008, 05:06 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Add a date to a form

I'm assuming you mean you want the CreateDate to be on a field in a table.
Simply putting a date on a form doesn't buy you much...

Set the field's DefaultValue to Date() (assuming all you want is the date),
or Now() (if you want both date and time). Whenever a new row is added to
the table, the field will pick up the default value. The Default Value will
have no effect on existing rows.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"AlastairO" wrote in message
news
I am wanting to add a CreateDate to a form which enters the date from the
computer system but doesn't update the next day.

Any helpers please!

Thanks

Alastair



  #3  
Old March 5th, 2008, 09:27 AM posted to microsoft.public.access.forms
AlastairO
external usenet poster
 
Posts: 2
Default Add a date to a form

Hi Doug,

Thank you for your quick response. Looking at your answer, I can see what
you are getting at and I have realised that my question wasn't specific
enough (sorry). What I am doing is setting up a field (in a table) that puts
in that day's date when tick boxes from 7 fields are completed - a completion
date as it were. If the boxes aren't all ticked then the field is empty.

Hopefully this is more specific. Thanks for your help and time.

Alastair

"Douglas J. Steele" wrote:

I'm assuming you mean you want the CreateDate to be on a field in a table.
Simply putting a date on a form doesn't buy you much...

Set the field's DefaultValue to Date() (assuming all you want is the date),
or Now() (if you want both date and time). Whenever a new row is added to
the table, the field will pick up the default value. The Default Value will
have no effect on existing rows.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"AlastairO" wrote in message
news
I am wanting to add a CreateDate to a form which enters the date from the
computer system but doesn't update the next day.

Any helpers please!

Thanks

Alastair




  #4  
Old March 5th, 2008, 12:47 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Add a date to a form

Put code in the form's BeforeUpdate event to check whether the 7 check boxes
are completed and whether no CompletionDate already exists. If so, set the
CompletionDate.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"AlastairO" wrote in message
...
Hi Doug,

Thank you for your quick response. Looking at your answer, I can see what
you are getting at and I have realised that my question wasn't specific
enough (sorry). What I am doing is setting up a field (in a table) that
puts
in that day's date when tick boxes from 7 fields are completed - a
completion
date as it were. If the boxes aren't all ticked then the field is empty.

Hopefully this is more specific. Thanks for your help and time.

Alastair

"Douglas J. Steele" wrote:

I'm assuming you mean you want the CreateDate to be on a field in a
table.
Simply putting a date on a form doesn't buy you much...

Set the field's DefaultValue to Date() (assuming all you want is the
date),
or Now() (if you want both date and time). Whenever a new row is added to
the table, the field will pick up the default value. The Default Value
will
have no effect on existing rows.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"AlastairO" wrote in message
news
I am wanting to add a CreateDate to a form which enters the date from
the
computer system but doesn't update the next day.

Any helpers please!

Thanks

Alastair






  #5  
Old March 5th, 2008, 01:02 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Add a date to a form

Yes, Alastair, asking for a "CreationDate" when you actually want a
"CompletionDate" is a little ambiguous! Here's two sets of code to do it. If
you ***only*** have 7 checkboxes on your form, in total


Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctrl As Control
Dim Counter As Integer

Counter = 0

For Each ctrl In Me.Controls
If TypeOf ctrl Is CheckBox Then
If ctrl = -1 Then
Counter = Counter + 1
End If
End If
Next

If IsNull(Me.DateCompleted) And Counter = 7 Then
Me.DateCompleted = Date
End If

End Sub

If, on the other hand, you have more than 7 checkboxes on your form, but are
only concerned with the magic 7 for you completion date, for each of those 7
you need to goto Properties - Other and enter "marked" (without the quotes)
in the Tag Property of each, then use this code instead:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctrl As Control
Dim Counter As Integer

Counter = 0

For Each ctrl In Me.Controls
If TypeOf ctrl Is CheckBox Then
If ctrl.Tag = "marked" And ctrl = -1 Then
Counter = Counter + 1
End If
End If
Next

If IsNull(Me.DateCompleted) And Counter = 7 Then
Me.DateCompleted = Date
End If

End Sub

This assumes that once all 7 are checked you won't go back and unmark any. If
you want this possibility addressed you'd have to have more code to cover the
possibility.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200803/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.